tommmmmm | 10 Apr 12:23 2012
Picon

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");

(Continue reading)

Michael Erskine | 10 Apr 13:27 2012

Re: Log4J doesn't work at all

I know this might sound daft but is your class actually trying to log anything?
Michael Erskine | 10 Apr 13:40 2012

Re: Log4J doesn't work at all

On 10 April 2012 12:27, Michael Erskine <msemtd <at> googlemail.com> wrote:
> I know this might sound daft but is your class actually trying to log anything?

OK, I see where you're coming from:
http://hc.apache.org/httpcomponents-client-ga/logging.html

...and you would expect the HttpClient to log to the console. I'm not
familiar with HttpClient but I would expect it to work.

Any luck with Commons Logging or Java Logging?

Any luck with Log4J for a simple application?

If you are new to logging and Log4J concepts I recommend starting off
by adding some simple logging to a simple console application (as per
http://logging.apache.org/log4j/1.2/manual.html under the
"Configuration" heading).

You mentioned Tomcat: Getting Log4j working correctly under Tomcat is
a few steps beyond simple! Are you using HttpClient at the server side
under Tomcat or as a standalone client?
tommmmmm | 10 Apr 14:16 2012
Picon

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.
tommmmmm | 10 Apr 15:09 2012
Picon

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?
Gary Gregory | 10 Apr 13:56 2012
Picon

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, tommmmmm <tommmmmm <at> 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");
>
(Continue reading)

Jacob Kjome | 10 Apr 15:34 2012

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
 tommmmmm <tommmmmm <at> 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>
> 
> 
(Continue reading)

tommmmmm | 10 Apr 16:08 2012
Picon

Re: Log4J doesn't work at all

On 10 April 2012 15:34, Jacob Kjome <hoju <at> 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.html<http://hc.apache.org/httpcomponents-client-ga/logging.html>
> [2] http://commons.apache.org/**logging/RELEASE-NOTES.txt<http://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?
Jacob Kjome | 10 Apr 16:32 2012

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?
(Continue reading)

tommmmmm | 10 Apr 18:43 2012
Picon

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
Jacob Kjome | 10 Apr 19:25 2012

Re: Log4J doesn't work at all

On Tue, 10 Apr 2012 18:43:21 +0200
 tommmmmm <tommmmmm <at> 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, 
(Continue reading)

tommmmmm | 10 Apr 19:37 2012
Picon

Re: Log4J doesn't work at all

On 10 April 2012 19:25, Jacob Kjome <hoju <at> 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
(Continue reading)

tommmmmm | 10 Apr 21:29 2012
Picon

Re: Log4J doesn't work at all

My debug for log4j:
log4j: Trying to find [log4j.xml] using context classloader
sun.misc.Launcher$AppClassLoader <at> 56e88e24.
log4j: Trying to find [log4j.xml] using
sun.misc.Launcher$AppClassLoader <at> 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 <at> 56e88e24.
log4j: Trying to find [log4j.properties] using
sun.misc.Launcher$AppClassLoader <at> 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].
(Continue reading)

Jacob Kjome | 10 Apr 22:30 2012

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
(Continue reading)

tommmmmm | 10 Apr 23:06 2012
Picon

Re: Log4J doesn't work at all

On 10 April 2012 22:30, Jacob Kjome <hoju <at> 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
(Continue reading)

Douglas E Wegscheid | 10 Apr 23:32 2012

Re: Log4J doesn't work at all

tommmmmm <tommmmmm <at> 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?
tommmmmm | 11 Apr 07:28 2012
Picon

Re: Log4J doesn't work at all

>
> 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,

Yes. The log4j debug (I posted earlier) says so. I also said I tested
various other settings (like presentation/different levels) - and they all
work with my code, but not with HttpClient's.

> 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?

I did. Did not help. Fyi, it was also 60KB+

--

-- 
Tomasz P.
tommmmmm | 11 Apr 11:13 2012
Picon

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 --->
(Continue reading)

Douglas E Wegscheid | 11 Apr 14:36 2012

Re: Log4J doesn't work at all

tommmmmm <tommmmmm <at> 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);
  }
(Continue reading)

tommmmmm | 11 Apr 17:55 2012
Picon

Re: Log4J doesn't work at all

2012/4/11 Douglas E Wegscheid <Douglas_E_Wegscheid <at> 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
(Continue reading)

Douglas E Wegscheid | 11 Apr 18:32 2012

Re: Log4J doesn't work at all

tommmmmm <tommmmmm <at> 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.
Douglas E Wegscheid | 11 Apr 18:34 2012

Re: Log4J doesn't work at all

tommmmmm <tommmmmm <at> gmail.com> wrote on 04/11/2012 11:55:59 AM:

> I got something pretty much the same.

try making a new project with >>exactly<< what I posted. Then we'll know 
if it's your environment, or that specific project....
tommmmmm | 11 Apr 18:45 2012
Picon

Re: Log4J doesn't work at all

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].
(Continue reading)

tommmmmm | 11 Apr 19:55 2012
Picon

Re: Log4J doesn't work at all

On 11 April 2012 18:45, tommmmmm <tommmmmm <at> 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]
(Continue reading)

Jacob Kjome | 11 Apr 23:19 2012

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
 tommmmmm <tommmmmm <at> 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
(Continue reading)

tommmmmm | 12 Apr 10:57 2012
Picon

Re: Log4J doesn't work at all

On 11 April 2012 23:19, Jacob Kjome <hoju <at> 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.
(Continue reading)

Douglas E Wegscheid | 11 Apr 23:22 2012

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_Wegscheid <at> whirlpool.com
"A wrong note played hesitatingly is a wrong note. A wrong note played 
with conviction is interpretation."

tommmmmm <tommmmmm <at> gmail.com> wrote on 04/11/2012 01:55:20 PM:

> On 11 April 2012 18:45, tommmmmm <tommmmmm <at> 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:
> >
(Continue reading)

ceki | 12 Apr 12:06 2012
Picon

Re: Log4J doesn't work at all

On 11.04.2012 19:55, tommmmmm 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, 
(Continue reading)

tommmmmm | 10 Apr 19:23 2012
Picon

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
Jacob Kjome | 10 Apr 19:36 2012

Re: Log4J doesn't work at all

On Tue, 10 Apr 2012 19:23:18 +0200
 tommmmmm <tommmmmm <at> 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.

(Continue reading)


Gmane