-
1. Re: commons-logging/log4j problem
pi1 Mar 10, 2006 2:33 AM (in response to pi1)Some my observations. It seems to me as i saw when debugging webapp, that my log4j.properties are not picked up and logger
Log log=LogFactory.getLog(TestServlet.class);
i retrieve gets appenders from JBoss, so it puts all log messages to server.log and console, but not to my myapp.html log file.
Can anybody help me to solve this problem? -
2. Re: commons-logging/log4j problem
starksm64 Mar 12, 2006 12:47 PM (in response to pi1)See http://wiki.jboss.org/wiki/Wiki.jsp?page=Logging for a start.
-
3. Re: commons-logging/log4j problem
pi1 Mar 13, 2006 3:05 AM (in response to pi1)I've read this wiki and i've done all accordingly to scoped logging to use my log4j.properties. Results i've got as in reply above. My question is how to log with commons-logging. When i log directly with log4j logger like:
Logger log=Logger.getLogger(TestServlet.class);
log.debug("testing");
it works. I need to log with commons-logging like:
Log log=LogFactory.getLog(TestServlet.class);
log.debug("testing");
In wiki i have not found anything about logging with commons-logging.
Any reply can be helpfull for me, thanks. -
4. Re: commons-logging/log4j problem
peterj Mar 13, 2006 11:01 AM (in response to pi1)Are you by any chance including the commons logging jar file in your WEB-INF/lib directory? If so, try removing it and see if that solves the problem. I used to use commons logging all the time in my applications and never had a problem getting my logging output from JBoss.
-
5. Re: commons-logging/log4j problem
pi1 Mar 13, 2006 11:14 AM (in response to pi1)In my case removing commons logging jar file from WEB-INF/lib directory doesn't solve the problem. Do you specify your appenders in JBoss log4j xml configuration file?
-
6. Re: commons-logging/log4j problem
peterj Mar 13, 2006 11:37 AM (in response to pi1)Yes I, specify my appenders in the JBoss log4j xml configuration file.
-
7. Re: commons-logging/log4j problem
pi1 Mar 14, 2006 2:37 AM (in response to pi1)Hi, PeterJ. If you define your appeners in JBoss log4j configuration file, how do you separate logs among your apps. Do you specify
<category name=com.myapp1>
<appender-ref ref="Appender1"/>
...
<category name=com.myapp2>
<appender-ref ref="Appender2"/>
so classes in package com.myapp1.* log with Appender1 and classes in com.myapp2.* log with Appender2? I can not do so, as my diffrent apps classes in packeges with the same name com.myapp.*.
Or do you use TCLFilter to filter apps by deploymentURL while logging (i have not even got it work with this filter)? Also i really want to keep my log4j properties in my own file, so user can easily adjust this settings without touching JBoss configuration. -
8. Re: commons-logging/log4j problem
pi1 Mar 14, 2006 6:37 AM (in response to pi1)I've found not so pretty solution how to force classloader to pick my own log4j.properties. I put implemenatation of Log4JLogger in my package e.c. com.myapp.Log4JLogger and added to commons-logging.properties line:
org.apache.commons.logging.Log=com.myapp.Log4JLogger
Maybe someone could help me to find more correct solution?
Regards. -
9. Re: commons-logging/log4j problem
starksm64 Mar 14, 2006 12:55 PM (in response to pi1)That is all you can do if you are relying on configuration of singletons automatically finding a local configuration based on the class loader. A patch to the commons-logging to allow for more dynamic discovery of the logger factory is in the works. See http://jira.jboss.com/jira/browse/JBAS-2933
-
10. Re: commons-logging/log4j problem
peterj Mar 14, 2006 12:58 PM (in response to pi1)For the work that I do, logging to the server.log is no problem for me, so I have not tried to separate the logging out to other files.
The main reason for my suggestion regarding the commons logging file location was the possibility that you are running into a class loader issue, which seems to be confirmed by your latest message. But after thinking about it some more, maybe I should have suggested that you put the commons logging jar file into your WEB-INF/lib directory.
By the way, one way of debugging a cloass loader issue is add the -verbose:class JVM option to the command line. The JVM will then tell you for each class loaded what jar file it came from.