You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Tom Eugelink <tb...@tbee.org> on 2003/11/17 13:16:43 UTC

Revamp: App-server independent log4j logging

I'm NOT stupid...

I hope.

The reason I joined this mailing list was because I had a 
auto-configuration problem, but it "went away"... BUT now it's back. Oh joy.

- I have Tomcat 4.1.12 with 1 context (my application).
- In my application I have
   * WEB-INF/lib/log4j.jar (latest stable)
   * WEB-INF/classes/log4j.properties
- In the Tomcat directory is no log4j.jar or properties.

Now, if I start Tomcat with "-Dlog4j.debug=true", I get NO debug output 
nor is my log4j.properties loaded, but I do not get log4j error messages 
about needing a log4j.properties (so it did find one), and there is 
log4j output being generated...

Why don't I get debug output?

If I copy a log4j.jar into Tomcat/server/lib, I do get debug output, but 
then it says:

	log4j: Could not find resource: [null]

Why isn't it looking into my web-inf/classes?

Please, tell me I'm not stupid.

Tom



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: Revamp: App-server independent log4j logging

Posted by Tom Eugelink <tb...@tbee.org>.
>> - I have Tomcat 4.1.12 with 1 context (my application).
> 
> you should upgrade.  4.1.29 is out and Tomcat-5, my personal favorite, 
> is just about to be fully released as 5.0.15 (or whichever version they 
> decide).

Ah, yes, but company prescribed versions and stuff are always a bummer.


>> - In the Tomcat directory is no log4j.jar or properties.
> 
> 
> "in the Tomcat directory"?  What does that mean?  TOMCAT_HOME?  

Nowhere in the Tomcat directory; not in the server, not in common, not 
in any subdirectory.


> Also, it would be hard to guarantee that there 
> is no log4j.properties anywhere in a place where Tomcat can see it such 
> as an arbitrary jar file in common/lib or shared/lib.  You never know.  

Ah, correct, there was one JAR file (emphasis on "was") that contained a 
log4j.properties file (all my jar files contain one) and I removed it. 
Forcefully. Was not very pretty. So now it can't find one anymore, see 
the "[null]" thing log4j is reporting.


> That's why I recommend against counting on auto-configuration.  It is 
> there for convenience, but doesn't always provide what you need.  Anyway...

But I like it! ;-) It allows me the have a config setup as developer and 
deploy that, but have a system manager override it. Or if I have a jar 
which has log4j and it will find at least some configuration file.


>> Now, if I start Tomcat with "-Dlog4j.debug=true", I get NO debug 
>> output nor is my log4j.properties loaded, but I do not get log4j error 
>> messages about needing a log4j.properties (so it did find one), and 
>> there is log4j output being generated...
>>
>> Why don't I get debug output?
> 
> That's a bit odd, I must say.

Ah, I must concur there...


> server/lib is not a place to put stuff for your webapp to see.  Even 
> much of Tomcat's common stuff can't see server/lib.  for instance, 
> common/lib can't see server/lib, although the converse is true.  
> Personally, I always put log4j.jar in common/lib and a log4j.xml (for 
> server logging only) in common/classes.  I then have the choice of 
> putting log4j.jar and log4j.xml in each webapp or just have log4j.xml in 
> each webapp, do manual configuration, and use a repository selector to 
> use the common log4j.jar in common/lib.

Hm. Point made. I've writting some addons to Tomcat and it got a kind of 
habbit to put stuff in "server".


>> Why isn't it looking into my web-inf/classes?
> 
> It should, I'm not sure why it isn't.  Webapps look in the 
> WebappClassLoader first before looking in a parent classloader (note 
> that this is opposite to normal Java2 classloading behavior where the 
> parent is usually searched first).  BTW, are you starting Tomcat up 
> using the standard startup scripts or starting Tomcat as a service?  

Yikes! Noooooo, normal script, so I have a good control of what's in and 
what's out and what JDK is used. (The same Tomcat version sometimes is 
started under JDK1.3, sometimes under JDK1.4.)


> The best policy here is to clean up your system 
> classpath.  Mine is a single period and nothing else which avoids this 
> whole issue whether or not I start via scripts or as a service.

Yup. Mine is too.


> This classloader stuff can drive one insane.

Oh, is that what it is, I was wondering why I was hanging upside down 
from our kitchen lamp.

Thanks! As soons as I've got the laptop reinstalled, I'll try all this.

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: Revamp: App-server independent log4j logging

Posted by Jacob Kjome <ho...@visi.com>.
At 01:16 PM 11/17/2003 +0100, you wrote:
>I'm NOT stupid...
>
>I hope.

I'm sure, not.

>The reason I joined this mailing list was because I had a 
>auto-configuration problem, but it "went away"... BUT now it's back. Oh joy.
>
>- I have Tomcat 4.1.12 with 1 context (my application).

you should upgrade.  4.1.29 is out and Tomcat-5, my personal favorite, is 
just about to be fully released as 5.0.15 (or whichever version they decide).

>- In my application I have
>   * WEB-INF/lib/log4j.jar (latest stable)
>   * WEB-INF/classes/log4j.properties

sounds about right.

>- In the Tomcat directory is no log4j.jar or properties.

"in the Tomcat directory"?  What does that 
mean?  TOMCAT_HOME?  common/classes?  Where?  Also, it would be hard to 
guarantee that there is no log4j.properties anywhere in a place where 
Tomcat can see it such as an arbitrary jar file in common/lib or 
shared/lib.  You never know.  That's why I recommend against counting on 
auto-configuration.  It is there for convenience, but doesn't always 
provide what you need.  Anyway...

>Now, if I start Tomcat with "-Dlog4j.debug=true", I get NO debug output 
>nor is my log4j.properties loaded, but I do not get log4j error messages 
>about needing a log4j.properties (so it did find one), and there is log4j 
>output being generated...
>
>Why don't I get debug output?

That's a bit odd, I must say.

>If I copy a log4j.jar into Tomcat/server/lib, I do get debug output, but 
>then it says:
>
>         log4j: Could not find resource: [null]

server/lib is not a place to put stuff for your webapp to see.  Even much 
of Tomcat's common stuff can't see server/lib.  for instance, common/lib 
can't see server/lib, although the converse is true.  Personally, I always 
put log4j.jar in common/lib and a log4j.xml (for server logging only) in 
common/classes.  I then have the choice of putting log4j.jar and log4j.xml 
in each webapp or just have log4j.xml in each webapp, do manual 
configuration, and use a repository selector to use the common log4j.jar in 
common/lib.

>Why isn't it looking into my web-inf/classes?

It should, I'm not sure why it isn't.  Webapps look in the 
WebappClassLoader first before looking in a parent classloader (note that 
this is opposite to normal Java2 classloading behavior where the parent is 
usually searched first).  BTW, are you starting Tomcat up using the 
standard startup scripts or starting Tomcat as a service?  Because if it is 
the latter, then you should check your system classpath.  The startup 
scripts eschew the system classpath.  Running as a service won't.  The best 
policy here is to clean up your system classpath.  Mine is a single period 
and nothing else which avoids this whole issue whether or not I start via 
scripts or as a service.

>Please, tell me I'm not stupid.

Again, you're not.  This classloader stuff can drive one insane.

>Tom
>

Jake 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org