Re: Log4J doesn't work at all
On 11 April 2012 23:19, Jacob Kjome h...@visi.com wrote: Selenium depends upon SLF4J. You may recall that I mentioned SLF4J in a previous email. In appears Selenium includes it's own SLF4J binding. It seems rather silly to me that they would include this as part of their main library rather than as a separate, optional, jar. I suggest you contact the Selenium developers and, possibly, the SLF4J developers to find a solution. In any case, if you are going to have SLF4J in your classpath and want to use Log4j as the implementation, you should include the following in the classpath jcl-over-slf4j.jar slf4j-api.jar slf4j-log4j12.jar log4j.jar And get rid of any, and all, commons-logging jars. The jcl-over-slf4j.jar contains the package/classes of commons-logging, except they are a re-implementation bound to SLF4J. Jake I have just rewritten all selenium code to HtmlUnit code. That's it Works now. I know I should write to Selenium (I did, but they are silent) and lcf4j but after 25hours of me hugging 10 lines of code till blood and tears all go out... no I rather go the easy way now. No more fighting. I just hope HtmlUnit will do the job for me and that I will never have to use selenium... that's it.
Re: Log4J doesn't work at all
On 11.04.2012 19:55, tomm wrote: [snip] I added/removed jars one by one of course it had to be the last one. When I removed /home/min/ucng/javaLibs/selenium-server-standalone-2.20.0.jar It started to work. However... I need selenium - it's my main browser. So when I added it back SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/min/ucng/javaLibs/pbapi-full-1.4.0.91/lib/test/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/min/ucng/javaLibs/selenium-server-standalone-2.20.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. Exception in thread main java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:99) at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:212) at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:190) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:401) As the warning message above shows, selenium-server-standalone-2.20.0.jar contains an SLF4J binding. It also contains the classes of an *older* version of slf4j-api.jar. Which explains the NoSuchMethodError exception about org.slf4j.spi.LocationAwareLogger.log method. Interestingly enough, selenium-server-standalone-2.21.0.jar released just a few hours ago does *not* bundle slf4j classes. Note: perhaps using a jar file which includes standalone in its name was the original error. (Disclaimer: I have never used selenium.) -- Ceki http://twitter.com/#!/ceki - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4J doesn't work at all
I used System.setProperty(log4j.defaultInitOverride, true); So I can get clean loading: log4j: Default initialization of overridden by log4j.defaultInitOverrideproperty. log4j: Parsing for [root] with value=[DEBUG, stdout]. log4j: Level token is [DEBUG]. log4j: Category root set to DEBUG log4j: Parsing appender named stdout. log4j: Parsing layout options for stdout. log4j: Setting property [conversionPattern] to [%5p [%c] %m%n]. log4j: End of parsing for stdout. log4j: Parsed stdout options. log4j: Parsing for [org.apache.http.wire] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http.wire set to DEBUG log4j: Handling log4j.additivity.org.apache.http.wire=[null] log4j: Parsing for [org.apache.http] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http set to DEBUG log4j: Handling log4j.additivity.org.apache.http=[null] log4j: Parsing for [jobManager] with value=[DEBUG]. --- That proves that MY config file is being loaded log4j: Level token is [DEBUG]. log4j: Category jobManager set to DEBUG log4j: Handling log4j.additivity.jobManager=[null] log4j: Finished configuring. DEBUG [jobManager.UploadManager] some test message --- Here should be output of HttpClient but its not --- DEBUG [jobManager.UploadManager] some test message I slept with the problem, yet no solutions came to my mind. For the sake of clarity here is output of: ClassLoader cl = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader) cl).getURLs(); for (URL url : urls) { System.out.println(url.getFile()); } /home/min/ucng/javaLibs/httpcomponents-client-4.1.3/lib/commons-codec-1.4.jar /home/min/ucng/javaLibs/httpcomponents-client-4.1.3/lib/httpclient-4.1.3.jar /home/min/ucng/javaLibs/httpcomponents-client-4.1.3/lib/httpclient-cache-4.1.3.jar /home/min/ucng/javaLibs/httpcomponents-client-4.1.3/lib/httpcore-4.1.4.jar /home/min/ucng/javaLibs/httpcomponents-client-4.1.3/lib/httpmime-4.1.3.jar /home/min/ucng/javaLibs/commons-logging-1.1.1/commons-logging-1.1.1.jar /home/min/ucng/javaLibs/apache-log4j-1.2.16/log4j-1.2.16.jar /home/min/ucng/javaLibs/commons-codec-1.6/commons-codec-1.6-javadoc.jar /home/min/ucng/javaLibs/commons-codec-1.6/commons-codec-1.6-tests.jar /home/min/ucng/javaLibs/commons-codec-1.6/commons-codec-1.6.jar /home/min/ucng/javaLibs/selenium-server-standalone-2.20.0.jar /home/min/ucng/javaLibs/scribe-1.3.0.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/pbapi-j2se.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/apache-mime4j-0.6.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/commons-codec-1.3.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/commons-codec-1.4.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/commons-lang-2.4.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/commons-logging-1.1.1.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/commons-validator-1.3.1.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/httpclient-4.0.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/httpclient-4.1.3.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/httpclient-cache-4.1.3.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/httpcore-4.0.1.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/httpcore-4.1.4.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/httpmime-4.0.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/httpmime-4.1.3.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/jcip-annotations-1.0.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/json-1.0.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/junit-4.9b2.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/log4j-1.2.16.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/signpost-commonshttp4-1.2.1.1.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/signpost-commonshttp4-1.2.1.2.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/signpost-core-1.2.1.1.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/signpost-core-1.2.1.2.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/signpost-jetty6-1.2.1.2.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/slf4j-api-1.6.1.jar /home/min/ucng/javaLibs/pbapi-full-1.4.0.91/dist/lib/default/slf4j-log4j12-1.6.1.jar The output of: System.out.println(httpClient.getClass().getClassLoader().getResource(log4j.properties)); is: null --- I don't know if it is relevant or not. I thought about log4j.jar being in a different folder than httpClient but it shouldn't matter since it's the classpath that rules over. I am really out of ideas. Help please :( q.q
Re: Log4J doesn't work at all
tomm tommm...@gmail.com wrote on 04/11/2012 01:28:23 AM: You indicated that you were going to grab a fresh commons-logging jar and use it. Did you, or did that step get lost in the shuffle? I did. Did not help. Fyi, it was also 60KB+ I made a new project in Eclipse, added all the jar files in httpcomponents-client-4.1.3 GA to a /lib folder, added log4j-1.2.16.jar to the same folder, put all the jars in that folder on my classpath, added these two files to src folder: Test1.java: import org.apache.http.*; import org.apache.http.client.*; import org.apache.http.client.methods.HttpHead; import org.apache.http.impl.client.DefaultHttpClient; // import org.apache.log4j.PropertyConfigurator; public class Test1 { public static void main (String[] args) { System.setProperty(log4j.debug, true); // PropertyConfigurator.configure(log4j.properties); int i = new Test1(args).go(); System.exit(i); } org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger( test.log4j); org.apache.commons.logging.Log commons = org.apache.commons.logging.LogFactory.getLog(test.commons); org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger (getClass()); Test1 (String[] args) { super(); } int go () { Throwable boom = null; try { logger.info(greeting from logger); log4j.info(greeting from log4j); commons.info(greeting from commons); HttpClient httpClient = new DefaultHttpClient(); HttpHead httpRequest = new HttpHead(http://xx/;); HttpResponse httpResponse = httpClient.execute(httpRequest); logger.info(response = + httpResponse.toString()); } catch (RuntimeException ex) { boom = ex; } catch (ClientProtocolException ex) { boom = ex; } catch (IOException ex) { boom = ex; } if (boom != null) boom.printStackTrace(); return 0; } } log4j.properties: log4j.properties: log4j.rootLogger=INFO,stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=from Log4J: %5p [%c] %m%n log4j.logger.org.apache.http=DEBUG log4j.logger.org.apache.http.wire=ERROR my output looks as I would expect (hostnames are xx'd out) log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@35ce36. log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@35ce36 class loader. log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource(). log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@35ce36. log4j: Using URL [file:/D:/data/Workspace-GJobs/HttpClient/bin/log4j.properties] for automatic log4j configuration. log4j: Reading configuration from URL file:/D:/data/Workspace-GJobs/HttpClient/bin/log4j.properties log4j: Parsing for [root] with value=[INFO,stdout]. log4j: Level token is [INFO]. log4j: Category root set to INFO log4j: Parsing appender named stdout. log4j: Parsing layout options for stdout. log4j: Setting property [conversionPattern] to [from Log4J: %5p [%c] %m%n]. log4j: End of parsing for stdout. log4j: Parsed stdout options. log4j: Parsing for [org.apache.http.wire] with value=[ERROR]. log4j: Level token is [ERROR]. log4j: Category org.apache.http.wire set to ERROR log4j: Handling log4j.additivity.org.apache.http.wire=[null] log4j: Parsing for [org.apache.http] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http set to DEBUG log4j: Handling log4j.additivity.org.apache.http=[null] log4j: Finished configuring. from Log4J: INFO [Test1] greeting from logger from Log4J: INFO [test.log4j] greeting from log4j from Log4J: INFO [test.commons] greeting from commons from Log4J: DEBUG [org.apache.http.impl.conn.SingleClientConnManager] Get connection for route HttpRoute[{}-http://xxx] from Log4J: DEBUG [org.apache.http.impl.conn.DefaultClientConnectionOperator] Connecting to xxx:80 from Log4J: DEBUG [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: best-match from Log4J: DEBUG [org.apache.http.client.protocol.RequestAuthCache] Auth cache not set in the context from Log4J: DEBUG [org.apache.http.impl.client.DefaultHttpClient] Attempt 1 to execute request from Log4J: DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Sending request: HEAD / HTTP/1.1 from Log4J: DEBUG [org.apache.http.headers] HEAD / HTTP/1.1 from Log4J: DEBUG [org.apache.http.headers] Host: xx from Log4J: DEBUG [org.apache.http.headers] Connection: Keep-Alive from Log4J: DEBUG [org.apache.http.headers] User-Agent: Apache-HttpClient/4.1.3 (java 1.5) from Log4J: DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Receiving response: HTTP/1.1 200 OK from Log4J: DEBUG [org.apache.http.headers] HTTP/1.1 200 OK from Log4J: DEBUG
Re: Log4J doesn't work at all
2012/4/11 Douglas E Wegscheid douglas_e_wegsch...@whirlpool.com I made a new project in Eclipse, added all the jar files in httpcomponents-client-4.1.3 GA to a /lib folder, added log4j-1.2.16.jar to the same folder, put all the jars in that folder on my classpath, added these two files to src folder: There was a difference - my log4j.jar was in different folder. I moved it to the same folder as httpclient and commons-logging. Didn't help. Test1.java: import org.apache.http.*; import org.apache.http.client.*; import org.apache.http.client.methods.HttpHead; import org.apache.http.impl.client.DefaultHttpClient; // import org.apache.log4j.PropertyConfigurator; public class Test1 { public static void main (String[] args) { System.setProperty(log4j.debug, true); // PropertyConfigurator.configure(log4j.properties); int i = new Test1(args).go(); System.exit(i); } here was another difference - I was logging from within static method not normal method. I changed it = didn't help. org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger( test.log4j); org.apache.commons.logging.Log commons = org.apache.commons.logging.LogFactory.getLog(test.commons); org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger (getClass()); Test1 (String[] args) { super(); } int go () { Throwable boom = null; try { logger.info(greeting from logger); log4j.info(greeting from log4j); commons.info(greeting from commons); HttpClient httpClient = new DefaultHttpClient(); HttpHead httpRequest = new HttpHead(http://xx/;); HttpResponse httpResponse = httpClient.execute(httpRequest); logger.info(response = + httpResponse.toString()); } catch (RuntimeException ex) { boom = ex; } catch (ClientProtocolException ex) { boom = ex; } catch (IOException ex) { boom = ex; } if (boom != null) boom.printStackTrace(); return 0; } } I got something pretty much the same. log4j.properties: log4j.properties: log4j.rootLogger=INFO,stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=from Log4J: %5p [%c] %m%n log4j.logger.org.apache.http=DEBUG log4j.logger.org.apache.http.wire=ERROR Exactly the same here my output looks as I would expect (hostnames are xx'd out) log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@35ce36. log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@35ce36 class loader. log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource(). log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@35ce36. log4j: Using URL [file:/D:/data/Workspace-GJobs/HttpClient/bin/log4j.properties] for automatic log4j configuration. log4j: Reading configuration from URL file:/D:/data/Workspace-GJobs/HttpClient/bin/log4j.properties log4j: Parsing for [root] with value=[INFO,stdout]. log4j: Level token is [INFO]. log4j: Category root set to INFO log4j: Parsing appender named stdout. log4j: Parsing layout options for stdout. log4j: Setting property [conversionPattern] to [from Log4J: %5p [%c] %m%n]. log4j: End of parsing for stdout. log4j: Parsed stdout options. log4j: Parsing for [org.apache.http.wire] with value=[ERROR]. log4j: Level token is [ERROR]. log4j: Category org.apache.http.wire set to ERROR log4j: Handling log4j.additivity.org.apache.http.wire=[null] log4j: Parsing for [org.apache.http] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http set to DEBUG log4j: Handling log4j.additivity.org.apache.http=[null] log4j: Finished configuring. from Log4J: INFO [Test1] greeting from logger from Log4J: INFO [test.log4j] greeting from log4j from Log4J: INFO [test.commons] greeting from commons My output stops here. from Log4J: DEBUG [org.apache.http.impl.conn.SingleClientConnManager] Get connection for route HttpRoute[{}-http://xxx] from Log4J: DEBUG [org.apache.http.impl.conn.DefaultClientConnectionOperator] Connecting to xxx:80 from Log4J: DEBUG [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: best-match from Log4J: DEBUG [org.apache.http.client.protocol.RequestAuthCache] Auth cache not set in the context from Log4J: DEBUG [org.apache.http.impl.client.DefaultHttpClient] Attempt 1 to execute request from Log4J: DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Sending request: HEAD / HTTP/1.1 from Log4J: DEBUG [org.apache.http.headers] HEAD / HTTP/1.1 from Log4J: DEBUG [org.apache.http.headers] Host: xx from Log4J: DEBUG [org.apache.http.headers] Connection: Keep-Alive from Log4J: DEBUG [org.apache.http.headers] User-Agent:
Re: Log4J doesn't work at all
tomm tommm...@gmail.com wrote on 04/11/2012 11:55:59 AM: I also added: org.apache.commons.logging.Log=org.apache.commons.logging. impl.Log4JLogger to commons-logging.properties to point commons-logging to log4j. Didn't help either. More ideas? Have you tried creating a new project with just these jars and just the Test1.java and log4j.properties and the jars I listed? If so, I'm stumped. If not, try it. You *must* have something different than I do (something else on the classpath), but I can't think of what it is. I've made it work with both Eclipse Indigo and Netbeans 6.9.1.
Re: Log4J doesn't work at all
On 11 April 2012 18:45, tomm tommm...@gmail.com wrote: I used the old project I had in my Projects list. And it works there flawlessly. For easier readability here are the results: Log4j configuration debug output in working project: **Start of LogManager static initializer *** configurationOptionStr=null ** End of LogManager static initializer DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [root] with value=[DEBUG, stdout]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category root set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Parsing appender named stdout. DEBUG [org.apache.log4j.PropertyConfigurator] Parsing layout options for stdout. DEBUG [org.apache.log4j.config.PropertySetter] Setting property [conversionPattern] to [%5p [%c] %m%n]. DEBUG [org.apache.log4j.PropertyConfigurator] End of parsing for stdout. DEBUG [org.apache.log4j.PropertyConfigurator] Parsed stdout options. DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [org.apache.http.wire] with value=[DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category org.apache.http.wire set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Handling log4j.additivity.org.apache.http.wire=[null] DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [org.apache.http] with value=[DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category org.apache.http set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Handling log4j.additivity.org.apache.http=[null] DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [stupidClass] with value=[DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category stupidClass set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Handling log4j.additivity.stupidClass=[null] DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [jobManager] with value=[DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category jobManager set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Handling log4j.additivity.jobManager=[null] DEBUG [org.apache.log4j.PropertyConfigurator] Finished configuring. Log4j configuration debug output in NOT working project: log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@2827f394. log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@2827f394 class loader. log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource(). log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@2827f394. log4j: Using URL [file:/home/min/ucng/ucng_java/sBorgJava/src/logging/log4j.properties] for automatic log4j configuration. log4j: Reading configuration from URL file:/home/min/ucng/ucng_java/sBorgJava/src/logging/log4j.properties log4j: Parsing for [root] with value=[DEBUG, stdout]. log4j: Level token is [DEBUG]. log4j: Category root set to DEBUG log4j: Parsing appender named stdout. log4j: Parsing layout options for stdout. log4j: Setting property [conversionPattern] to [%5p [%c] %m%n]. log4j: End of parsing for stdout. log4j: Parsed stdout options. log4j: Parsing for [org.apache.http.wire] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http.wire set to DEBUG log4j: Handling log4j.additivity.org.apache.http.wire=[null] log4j: Parsing for [org.apache.http] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http set to DEBUG log4j: Handling log4j.additivity.org.apache.http=[null] log4j: Parsing for [stupidClass] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category stupidClass set to DEBUG log4j: Handling log4j.additivity.stupidClass=[null] log4j: Parsing for [jobManager] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category jobManager set to DEBUG log4j: Handling log4j.additivity.jobManager=[null] log4j: Finished configuring. log4j: Parsing for [root] with value=[DEBUG, stdout]. log4j: Level token is [DEBUG]. log4j: Category root set to DEBUG log4j: Parsing appender named stdout. log4j: Parsing layout options for stdout. log4j: Setting property [conversionPattern] to [%5p [%c] %m%n]. log4j: End of parsing for stdout. log4j: Parsed stdout options. log4j: Parsing for [org.apache.http.wire] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http.wire set to DEBUG log4j: Handling log4j.additivity.org.apache.http.wire=[null] log4j: Parsing for [org.apache.http] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http set to DEBUG log4j: Handling
Re: Log4J doesn't work at all
Selenium depends upon SLF4J. You may recall that I mentioned SLF4J in a previous email. In appears Selenium includes it's own SLF4J binding. It seems rather silly to me that they would include this as part of their main library rather than as a separate, optional, jar. I suggest you contact the Selenium developers and, possibly, the SLF4J developers to find a solution. In any case, if you are going to have SLF4J in your classpath and want to use Log4j as the implementation, you should include the following in the classpath jcl-over-slf4j.jar slf4j-api.jar slf4j-log4j12.jar log4j.jar And get rid of any, and all, commons-logging jars. The jcl-over-slf4j.jar contains the package/classes of commons-logging, except they are a re-implementation bound to SLF4J. Jake On Wed, 11 Apr 2012 19:55:20 +0200 tomm tommm...@gmail.com wrote: I added/removed jars one by one of course it had to be the last one. When I removed /home/min/ucng/javaLibs/selenium-server-standalone-2.20.0.jar It started to work. However... I need selenium - it's my main browser. So when I added it back SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/min/ucng/javaLibs/pbapi-full-1.4.0.91/lib/test/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/min/ucng/javaLibs/selenium-server-standalone-2.20.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. Exception in thread main java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:99) at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:212) at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:190) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:401) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732) at jobManager.UploadManager.main2(UploadManager.java:135) at jobManager.UploadManager.main(UploadManager.java:44) Java Result: 1 And when I removed the extra slf4j as jar:file:/home/min/ucng/javaLibs/pbapi-full-1.4.0.91/lib/test/slf4j-log4j12-1.6.1.jar Then I go back to a project that compiles but doesn't show output of HttpClient logger. Now I am like this @_@ What has some wierd slf4j to commons-logging or log4j. And what it has to do with HttpClient... I am so so so so confused. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4J doesn't work at all
woho! slf4j is in there! you have 2 copies of a slf4j binding loaded, one in the slf4j jar, one in the selenium jar. slf4j docs say it should use the first one found, which means slf should be binding to log4j. slf4j may be catching all the common-logging messages. You have a mess here: multiple versions of the same classes loading from different jars (httpclient, slf4j, commons logging). I wouldn't even hazard how to fix it with things in such disarray. Jacob was right: it's usually a classpath problem. Eliminating the duplicate jars (if you are using slf4j, the only commons-logging jar you need is commons-logging-api). I don't know how to keep the slf4j configuration bundled into the selenium jar from bunging up everything else. It's not HttpComponents that has the problem, and log4j is working just fine. I'd take it to the slf4j list if you continue to have problems... ■ DOUGLAS E. WEGSCHEID // LEAD ENGINEER (269) 923-5278 // douglas_e_wegsch...@whirlpool.com A wrong note played hesitatingly is a wrong note. A wrong note played with conviction is interpretation. tomm tommm...@gmail.com wrote on 04/11/2012 01:55:20 PM: On 11 April 2012 18:45, tomm tommm...@gmail.com wrote: I used the old project I had in my Projects list. And it works there flawlessly. For easier readability here are the results: Log4j configuration debug output in working project: **Start of LogManager static initializer *** configurationOptionStr=null ** End of LogManager static initializer DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [root] with value=[DEBUG, stdout]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category root set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Parsing appender named stdout. DEBUG [org.apache.log4j.PropertyConfigurator] Parsing layout options for stdout. DEBUG [org.apache.log4j.config.PropertySetter] Setting property [conversionPattern] to [%5p [%c] %m%n]. DEBUG [org.apache.log4j.PropertyConfigurator] End of parsing for stdout. DEBUG [org.apache.log4j.PropertyConfigurator] Parsed stdout options. DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [org.apache.http.wire] with value=[DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category org.apache.http.wire set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Handling log4j.additivity.org.apache.http.wire=[null] DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [org.apache.http] with value=[DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category org.apache.http set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Handling log4j.additivity.org.apache.http=[null] DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [stupidClass] with value=[DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category stupidClass set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Handling log4j.additivity.stupidClass=[null] DEBUG [org.apache.log4j.PropertyConfigurator] Parsing for [jobManager] with value=[DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Level token is [DEBUG]. DEBUG [org.apache.log4j.PropertyConfigurator] Category jobManager set to DEBUG. DEBUG [org.apache.log4j.PropertyConfigurator] Handling log4j.additivity.jobManager=[null] DEBUG [org.apache.log4j.PropertyConfigurator] Finished configuring. Log4j configuration debug output in NOT working project: log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@2827f394. log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@2827f394 class loader. log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource(). log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@2827f394. log4j: Using URL [file:/home/min/ucng/ucng_java/sBorgJava/src/logging/log4j.properties] for automatic log4j configuration. log4j: Reading configuration from URL file:/home/min/ucng/ucng_java/sBorgJava/src/logging/log4j.properties log4j: Parsing for [root] with value=[DEBUG, stdout]. log4j: Level token is [DEBUG]. log4j: Category root set to DEBUG log4j: Parsing appender named stdout. log4j: Parsing layout options for stdout. log4j: Setting property [conversionPattern] to [%5p [%c] %m%n]. log4j: End of parsing for stdout. log4j: Parsed stdout options. log4j: Parsing for [org.apache.http.wire] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http.wire set to DEBUG log4j: Handling log4j.additivity.org.apache.http.wire=[null] log4j: Parsing for [org.apache.http]
Log4J doesn't work at all
From: http://hc.apache.org/httpcomponents-client-ga/logging.html I copy pasted log4j.rootLogger=INFO, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n log4j.logger.org.apache.http=DEBUG log4j.logger.org.apache.http.wire=ERROR Into a file I named log4j.properties that I put into src folder a'ka default package Didn't work at all. Then I put this in my class: System.setProperty(log4j.rootLogger, INFO, stdout); System.setProperty(log4j.appender.stdout, org.apache.log4j.ConsoleAppender); System.setProperty(log4j.appender.stdout.layout, org.apache.log4j.PatternLayout); System.setProperty(log4j.appender.stdout.layout.ConversionPattern, %5p [%c] %m%n); System.setProperty(log4j.logger.org.apache.http.client, DEBUG); System.setProperty(log4j.logger.org.apache.http, DEBUG); System.setProperty(log4j.logger.org.apache.http.wire, DEBUG); Yet it didn't work at all either. No additional output was produced. How do you make it work? ps: at: http://logging.apache.org/log4j/1.2/manual.html It's not written how to do it (empty paragraph Example Configurations and non empty yet ultimately useless Tomcat paragraph).
Re: Log4J doesn't work at all
I know this might sound daft but is your class actually trying to log anything? - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4J doesn't work at all
See http://logging.apache.org/log4j/1.2/manual.html under Default Initialization Procedure Gary On Tue, Apr 10, 2012 at 6:23 AM, tomm tommm...@gmail.com wrote: From: http://hc.apache.org/httpcomponents-client-ga/logging.html I copy pasted log4j.rootLogger=INFO, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n log4j.logger.org.apache.http=DEBUG log4j.logger.org.apache.http.wire=ERROR Into a file I named log4j.properties that I put into src folder a'ka default package Didn't work at all. Then I put this in my class: System.setProperty(log4j.rootLogger, INFO, stdout); System.setProperty(log4j.appender.stdout, org.apache.log4j.ConsoleAppender); System.setProperty(log4j.appender.stdout.layout, org.apache.log4j.PatternLayout); System.setProperty(log4j.appender.stdout.layout.ConversionPattern, %5p [%c] %m%n); System.setProperty(log4j.logger.org.apache.http.client, DEBUG); System.setProperty(log4j.logger.org.apache.http, DEBUG); System.setProperty(log4j.logger.org.apache.http.wire, DEBUG); Yet it didn't work at all either. No additional output was produced. How do you make it work? ps: at: http://logging.apache.org/log4j/1.2/manual.html It's not written how to do it (empty paragraph Example Configurations and non empty yet ultimately useless Tomcat paragraph). -- E-Mail: garydgreg...@gmail.com | ggreg...@apache.org JUnit in Action, 2nd Ed: http://bit.ly/ECvg0 Spring Batch in Action: http://bit.ly/bqpbCK Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory http://twitter.com/GaryGregory
Re: Log4J doesn't work at all
In reply to the questions: By Michael Erskine 1. I know this might sound daft but is your class actually trying to log anything? 2. Any luck with Log4J for a simple application? 3. Are you using HttpClient at the server side under Tomcat or as a standalone client? 1. Yes it does. I use: PropertyConfigurator.configure(./src/logging/log4j.properties); And shortly after logger.debug(some test message); just to test IF the proprties file was loaded and if it was loaded correctly. Yes it was. 2. logger.debug(some test message); - works. 3. Standalone client By Gary Gregory: 1. See Default Initialization Procedure 1. Just in case I added *log4j.defaultInitOverride=true *Didn't work. Also IF the configuration file specified by me was somehow overridden, then logger.debug(some test message); wouldn't work. And it works exactly as specified with configuration file I provided. I tested it with different levels than just debug level.
Re: Log4J doesn't work at all
I did this for a test: logger.debug(some test message); // - DOES get printed. my_code_here_based_on_HttpClient; // - should produce tons of logging output logger.debug(some test message); // - DOES get printed. So why the middle part doesn't produce any output? Just to recall I am using log4j.rootLogger=DEBUG, stdout so it shouldn't matter what and why. I am really puzzled now. Why the middle part doesn't produce any output?
Re: Log4J doesn't work at all
That system property stuff only applies to commons-logging, not Log4j. Look more closely at the instructions [1]. BTW, are you using commons-logging-api.jar? If so, that's the problem. You need commons-logging.jar. See the commons-logging release notes [2]. [1] http://hc.apache.org/httpcomponents-client-ga/logging.html [2] http://commons.apache.org/logging/RELEASE-NOTES.txt Jake On Tue, 10 Apr 2012 12:23:55 +0200 tomm tommm...@gmail.com wrote: From: http://hc.apache.org/httpcomponents-client-ga/logging.html I copy pasted log4j.rootLogger=INFO, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n log4j.logger.org.apache.http=DEBUG log4j.logger.org.apache.http.wire=ERROR Into a file I named log4j.properties that I put into src folder a'ka default package Didn't work at all. Then I put this in my class: System.setProperty(log4j.rootLogger, INFO, stdout); System.setProperty(log4j.appender.stdout, org.apache.log4j.ConsoleAppender); System.setProperty(log4j.appender.stdout.layout, org.apache.log4j.PatternLayout); System.setProperty(log4j.appender.stdout.layout.ConversionPattern, %5p [%c] %m%n); System.setProperty(log4j.logger.org.apache.http.client, DEBUG); System.setProperty(log4j.logger.org.apache.http, DEBUG); System.setProperty(log4j.logger.org.apache.http.wire, DEBUG); Yet it didn't work at all either. No additional output was produced. How do you make it work? ps: at: http://logging.apache.org/log4j/1.2/manual.html It's not written how to do it (empty paragraph Example Configurations and non empty yet ultimately useless Tomcat paragraph). - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4J doesn't work at all
On 10 April 2012 15:34, Jacob Kjome h...@visi.com wrote: That system property stuff only applies to commons-logging, not Log4j. Look more closely at the instructions [1]. BTW, are you using commons-logging-api.jar? If so, that's the problem. You need commons-logging.jar. See the commons-logging release notes [2]. [1] http://hc.apache.org/**httpcomponents-client-ga/**logging.htmlhttp://hc.apache.org/httpcomponents-client-ga/logging.html [2] http://commons.apache.org/**logging/RELEASE-NOTES.txthttp://commons.apache.org/logging/RELEASE-NOTES.txt Jake But I don't want to use commons-logging. I want to use log4j. In any case, that System.property stuff didn't help either. Part of the code simply gets. ignored. Why?
Re: Log4J doesn't work at all
But I don't want to use commons-logging. I want to use log4j. You are missing the point. **You** want to use Log4j. That's fine. But HttpClient doesn't directly use Log4j. It directly uses commons-logging, which is a Logger adapter that supports various logging implementations, one of which is Log4j. If you want to use Log4j, then you ***have*** to use commons-logging.jar, and NOT commons-logging-api.jar, plus log4j.jar. To avoid commons-logging (and some of the problems it can create), you can skip commons-logging.jar and use SLF4J [1]: jcl-over-slf4j.jar + slf4j-api.jar + slf4j-log4j12.jar + log4j.jar. But either way, you can't avoid having the commons-logging packages/classes (which jcl-over-slf4j.jar mimics) in the classpath because HttpClient has a hard dependency on it. In any case, that System.property stuff didn't help either. Because it's commons-logging specific and totally irrelevant to Log4j. Besides, you were setting Log4j packages as properties and that is totally meaningless. For instance, you wrote... System.setProperty(log4j.logger.org.apache.http.client, DEBUG); But HttpClient's instructions say to do (again, read the instructions more closely)... System.setProperty(org.apache.commons.logging.simplelog.log.org.apache.http.wire, DEBUG); Part of the code simply gets. ignored. Why? Because you are not following instructions. [1] http://slf4j.org/legacy.html#jcl-over-slf4j Jake On Tue, 10 Apr 2012 16:08:07 +0200 tomm tommm...@gmail.com wrote: On 10 April 2012 15:34, Jacob Kjome h...@visi.com wrote: That system property stuff only applies to commons-logging, not Log4j. Look more closely at the instructions [1]. BTW, are you using commons-logging-api.jar? If so, that's the problem. You need commons-logging.jar. See the commons-logging release notes [2]. [1] http://hc.apache.org/**httpcomponents-client-ga/**logging.htmlhttp://hc.apache.org/httpcomponents-client-ga/logging.html [2] http://commons.apache.org/**logging/RELEASE-NOTES.txthttp://commons.apache.org/logging/RELEASE-NOTES.txt Jake But I don't want to use commons-logging. I want to use log4j. In any case, that System.property stuff didn't help either. Part of the code simply gets. ignored. Why? - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4J doesn't work at all
There is no commons-logging-api.jar in my classpath anywhere. There is commons-logging-1.1.1.jar (there are 2 of them actually). There is only one log4j in my classpath and it is log4j-1.2.16.jar I highly doubt a problem to be a classpath problem, because then the logger.debug(some test message); would produce nothing, and it works well. Tom
Re: Log4J doesn't work at all
System.setProperty(log4j.**logger.org.apache.http.client**, DEBUG); But HttpClient's instructions say to do (again, read the instructions more closely)... System.setProperty(org.**apache.commons.logging.** simplelog.log.org.apache.http.**wire, DEBUG); For the record, you are refering to HttpClient 3.x HttpClient 3.x logging works perfectly for me, straight off the bat. HttpClient 4.x doesn't work at all. And it has different syntax. Just for the sake of it - I used old syntax with new HttpClient - no output generated. Tom
Re: Log4J doesn't work at all
On Tue, 10 Apr 2012 18:43:21 +0200 tomm tommm...@gmail.com wrote: There is no commons-logging-api.jar in my classpath anywhere. There is commons-logging-1.1.1.jar (there are 2 of them actually). There is only one log4j in my classpath and it is log4j-1.2.16.jar Are the jars binary identical? That is, are they exactly the same size with exactly the same contents? What size are they? 52k would indicate it is the API jar (bad) by another name, 60k would indicate it really is the complete commons-logging.jar (good). Why do you have two of them on the classpath anyway? Are you running on the command line or under an App Server like Tomcat? If under an app server (provide name/version), do you put all your lib dependencies, including log4j.jar and commons-logging.jar, in WEB-INF/lib or elsewhere? If elsewhere, please detail. I highly doubt a problem to be a classpath problem, because then the logger.debug(some test message); would produce nothing, and it works well. That you can log directly to Log4j is good, but is of no consequence as it relates to HttpClient logging. The cause of your issue is almost certainly commons-logging, not Log4j, because HttpClient logs directly to commons-logging. It is the job of commons-logging to direct this logging to Log4j which it is, apparently, failing to do. The reason I need you to verify that you are not, in fact, using the commons-logging API jar is that it has no Log4j binding and, thus, would explain the lack of Log4j output. If you are, indeed, using the complete commons-logging.jar, containing Log4j bindings, then we need to look for other causes. And, BTW, these things are almost **always** classpath/classloading issues. Tom Jake - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4J doesn't work at all
On Tue, 10 Apr 2012 19:23:18 +0200 tomm tommm...@gmail.com wrote: System.setProperty(log4j.**logger.org.apache.http.client**, DEBUG); But HttpClient's instructions say to do (again, read the instructions more closely)... System.setProperty(org.**apache.commons.logging.** simplelog.log.org.apache.http.**wire, DEBUG); For the record, you are refering to HttpClient 3.x HttpClient 3.x logging works perfectly for me, straight off the bat. I'm referring to the page you provided which provides instructions, of which the only ones that have anything to do with setting system properties to configure logging are the commons-logging examples [1]. In fact, I see no mention of version 3.x. The page appears to be exclusively for 4.x. If this is wrong, then file a bug with the HttpComponents project. HttpClient 4.x doesn't work at all. And it has different syntax. Just for the sake of it - I used old syntax with new HttpClient - no output generated. What old syntax? The syntax documented on the page? Again, if that's old, then file a bug with HttpComponents. In any case, clearly Log4j generally works for you, since it works when you log directly as well as with HttpClient-3.x. The difference appears to be the HttpClient version. Therefore, I suggest you ask the HttpClient developers. I'm not sure what else to tell you? Tom [1] http://hc.apache.org/httpcomponents-client-ga/logging.html#Commons_Logging_Examples Jake - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4J doesn't work at all
On 10 April 2012 19:25, Jacob Kjome h...@visi.com wrote: On Tue, 10 Apr 2012 18:43:21 +0200 Are the jars binary identical? That is, are they exactly the same size with exactly the same contents? One is 60.7 KB and one is 60.8 KB What size are they? 52k would indicate it is the API jar (bad) by another name, 60k would indicate it really is the complete commons-logging.jar (good). Why do you have two of them on the classpath anyway? Because when I add a jar that has it's own dependencies I add it via Tools - Libraries - Add new. This way my project (right click) - Properties - Libraries looks way cleaner. It only shows main jars and not absolutely all jars. Are you running on the command line or under an App Server like Tomcat? If under an app server (provide name/version), do you put all your lib dependencies, including log4j.jar and commons-logging.jar, in WEB-INF/lib or elsewhere? If elsewhere, please detail. Running command line. From within NetBeans. No fancy stuff. That you can log directly to Log4j is good, but is of no consequence as it relates to HttpClient logging. The cause of your issue is almost certainly commons-logging, not Log4j, because HttpClient logs directly to commons-logging. It is the job of commons-logging to direct this logging to Log4j which it is, apparently, failing to do. The reason I need you to verify that you are not, in fact, using the commons-logging API jar is that it has no Log4j binding and, thus, would explain the lack of Log4j output. If you are, indeed, using the complete commons-logging.jar, containing Log4j bindings, then we need to look for other causes. And, BTW, these things are almost **always** classpath/classloading issues As far as classloading goes, on the libraries list, I put log4j at the top and HttpClient right after it. The other jar that was using commons-logging ('pbapi.jar' - unrelated) I put on bottom. I will try to download commons-logging from main website and point HttpClient to it manually.
Re: Log4J doesn't work at all
My debug for log4j: log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@56e88e24. log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@56e88e24 class loader. log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource(). log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@56e88e24. log4j: Trying to find [log4j.properties] using sun.misc.Launcher$AppClassLoader@56e88e24 class loader. log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource(). log4j: Could not find resource: [null]. log4j: Parsing for [root] with value=[DEBUG, stdout]. log4j: Level token is [DEBUG]. log4j: Category root set to DEBUG log4j: Parsing appender named stdout. log4j: Parsing layout options for stdout. log4j: Setting property [conversionPattern] to [%5p [%c] %m%n]. log4j: End of parsing for stdout. log4j: Parsed stdout options. log4j: Parsing for [org.apache.http.wire] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http.wire set to DEBUG log4j: Handling log4j.additivity.org.apache.http.wire=[null] log4j: Parsing for [org.apache.http] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http set to DEBUG log4j: Handling log4j.additivity.org.apache.http=[null] log4j: Parsing for [jobManager] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category jobManager set to DEBUG log4j: Handling log4j.additivity.jobManager=[null] log4j: Finished configuring. My output for System.out.println(httpClient.getClass().getClassLoader().getResource(log4j.properties)); is: null It seems the httpClient is not using the logger properties I specified. But I thought that's why there was this line: log4j.logger.org.apache.http=DEBUG in the first place. I am so confused. Any hints?
Re: Log4J doesn't work at all
In your other email you say... Running command line. From within NetBeans. No fancy stuff. Never discount the complexity of an IDE and how it forks JVMs and/or performs idiosyncratic classloading. In any case, your test below is invalid in this context. You claimed, in an earlier response, that you load your config manually using... PropertyConfigurator.configure(./src/logging/log4j.properties); The output you see from Log4j, ending with the line... log4j: Could not find resource: [null]. ...just means that Log4j default config lookup didn't find a Log4j config file in the root of the classpath. That's normal if you didn't put it there. But because you manually configure, your config is loaded, so you can ignore the above line. The one odd thing I see is that there is a logger named jobManager that is configured. I don't see that in the log4 config you posted in a previous response (see below). Are you sure the config file that is being loaded is the one you **think** is being loaded? I copy pasted log4j.rootLogger=INFO, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n log4j.logger.org.apache.http=DEBUG log4j.logger.org.apache.http.wire=ERROR Into a file I named log4j.properties that I put into src folder a'ka default package BTW, why do you configure a properties file from a src folder. Why not just copy that into some folder on the classpath and let Log4j auto-configure. Besides, your methodology of using... PropertyConfigurator.configure(./src/logging/log4j.properties); ...suffers from the fact that this is a file path, relative to the directory from which the JVM started. That is bound to change from environment to environment and, therefore, brittle. Just stick it in the classpath and let Log4j pick it up. Jake On Tue, 10 Apr 2012 21:29:51 +0200 tomm tommm...@gmail.com wrote: My debug for log4j: log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@56e88e24. log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@56e88e24 class loader. log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource(). log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@56e88e24. log4j: Trying to find [log4j.properties] using sun.misc.Launcher$AppClassLoader@56e88e24 class loader. log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource(). log4j: Could not find resource: [null]. log4j: Parsing for [root] with value=[DEBUG, stdout]. log4j: Level token is [DEBUG]. log4j: Category root set to DEBUG log4j: Parsing appender named stdout. log4j: Parsing layout options for stdout. log4j: Setting property [conversionPattern] to [%5p [%c] %m%n]. log4j: End of parsing for stdout. log4j: Parsed stdout options. log4j: Parsing for [org.apache.http.wire] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http.wire set to DEBUG log4j: Handling log4j.additivity.org.apache.http.wire=[null] log4j: Parsing for [org.apache.http] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category org.apache.http set to DEBUG log4j: Handling log4j.additivity.org.apache.http=[null] log4j: Parsing for [jobManager] with value=[DEBUG]. log4j: Level token is [DEBUG]. log4j: Category jobManager set to DEBUG log4j: Handling log4j.additivity.jobManager=[null] log4j: Finished configuring. My output for System.out.println(httpClient.getClass().getClassLoader().getResource(log4j.properties)); is: null It seems the httpClient is not using the logger properties I specified. But I thought that's why there was this line: log4j.logger.org.apache.http=DEBUG in the first place. I am so confused. Any hints? - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4J doesn't work at all
On 10 April 2012 22:30, Jacob Kjome h...@visi.com wrote: In your other email you say... Running command line. From within NetBeans. No fancy stuff. Never discount the complexity of an IDE and how it forks JVMs and/or performs idiosyncratic classloading. I load/run only 1 JVM at a time. 1 Thread I might add. No forking here. In any case, your test below is invalid in this context. You claimed, in an earlier response, that you load your config manually using... PropertyConfigurator.**configure(./src/logging/**log4j.properties); The output you see from Log4j, ending with the line... log4j: Could not find resource: [null]. As the log4j debug stays, the file is being found and loaded after all. ...just means that Log4j default config lookup didn't find a Log4j config file in the root of the classpath. That's normal if you didn't put it there. But because you manually configure, your config is loaded, so you can ignore the above line. The one odd thing I see is that there is a logger named jobManager that is configured. I don't see that in the log4 config you posted in a previous response (see below). Are you sure the config file that is being loaded is the one you **think** is being loaded? First, I have to make it work. I can always add an entry in proprties file for a specific class later on. First it must work - then I will worry about details. I copy pasted log4j.rootLogger=INFO, stdout log4j.appender.stdout=org.**apache.log4j.ConsoleAppender log4j.appender.stdout.layout=**org.apache.log4j.PatternLayout log4j.appender.stdout.layout.**ConversionPattern=%5p [%c] %m%n log4j.logger.org.apache.http=**DEBUG log4j.logger.org.apache.http.**wire=ERROR Into a file I named log4j.properties that I put into src folder a'ka default package BTW, why do you configure a properties file from a src folder. Why not just copy that into some folder on the classpath and let Log4j auto-configure. Besides, your methodology of using... PropertyConfigurator.**configure(./src/logging/**log4j.properties); ...suffers from the fact that this is a file path, relative to the directory from which the JVM started. Alright. It will change. But it's on my super bottom list of worries. I first have to make it work. Then worry about the rest. That is bound to change from environment to environment and, therefore, brittle. Just stick it in the classpath and let Log4j pick it up. Has been already done sir ^^ Didn't help :( Jake :(
Re: Log4J doesn't work at all
tomm tommm...@gmail.com wrote on 04/10/2012 05:06:20 PM: The one odd thing I see is that there is a logger named jobManager that is configured. I don't see that in the log4 config you posted in a previous response (see below). Are you sure the config file that is being loaded is the one you **think** is being loaded? First, I have to make it work. I can always add an entry in proprties file for a specific class later on. First it must work - then I will worry about details. the log4j properties that you originally posted has nothing in it about jobManager; the output indicates that the one getting used does have settings for jobManager. Jacob has asked a question that may or may not be salient: are you sure the config file that is being loaded is the one you **think** is being loaded, or has the log4j.properties morphed along the way, and the file getting used is indeed the one that think is being used? You indicated that you were going to grab a fresh commons-logging jar and use it. Did you, or did that step get lost in the shuffle?