RE: Revamp: App-server independent log4j logging

2003-11-18 Thread Ken . Liu
Tom -

Try this:

1)  Make sure that log4j.jar is only in WEB-INF/lib.
2)  Make sure that log4j.properties is only in WEB-INF/classes.
3)  Make sure you are setting up tomcat correctly with the debug flag
properly.
  On the command line, set JAVA_OPTS=-Dlog4j.debug=true
4)  Create a new context under tomcat/webapps, and put in it only
WEB-INF/lib/log4j.jar and WEB-INF/classes/log4j.properties 
5)  Create a test jsp in the new context that calls Logger.getLogger() and
logs a single message
6)  Startup Tomcat startup.bat
7)  Hit the test jsp with your browser.

If this works, then I think there is something peculiar with your app's
configuration and not with the log4j setup.

Some more thoughts that might be of help:
1)  If you see log4j: Could not find resource: [null], this means that
log4j went through its default initialization routine, but couldn't find
log4j.properties or log4j.xml (see LogManager.java).  The initialization
routine probably happens when you first call Logger.getLogger().  It also
means that log4j.debug was set correctly, since the message only appears
when the debug flag is set.
2)  The message about no appenders found goes to stderr, not stdout.  I'm
not too familiar with Tomcat logging, but I think there is a separate stderr
log.

Ken

 -Original Message-
 From: Tom Eugelink [mailto:[EMAIL PROTECTED]
 Sent: Monday, November 17, 2003 7:17 AM
 To: Log4J Users List
 Subject: 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Revamp: App-server independent log4j logging

2003-11-17 Thread Tom Eugelink
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Revamp: App-server independent log4j logging

2003-11-17 Thread Tom Eugelink
Given that log4j.jar is in server/lib, I don't think it's reasonable to
expect Tomcat to go look in an arbitrary context/WEB-INF/classes for a
.properties file.  (How would it know which one?)
Log4j searches the whole classpath, so if I put a properties file in 
classes, it is found indeed (this is what I've done as a workaround). 
The thing is, the classes directory in my webapp is also part of the 
classpath, and it should have found the file there...

Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Revamp: App-server independent log4j logging

2003-11-17 Thread Wendy Smoak
 Log4j searches the whole classpath, so if I put a properties file in 
 classes, it is found indeed (this is what I've done as a workaround).
 The thing is, the classes directory in my webapp is also part of the 
 classpath, and it should have found the file there...

I don't think so.  There is more than one classloader involved, and so
more than one classpath.  For each webapp, Tomcat gathers up all the
necessary stuff from WEB-INF/classes and WEB-INF/lib plus anything in
'common' and that's the classpath for that particular webapp.

Tomcat itself, the server, has its own classpath.  That classloader
doesn't know or care about any of the webapps.  So I'm fairly certain
you have to put the .properties file in the 'server' section to match
the log4j.jar file in server/lib.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM  





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Revamp: App-server independent log4j logging

2003-11-17 Thread Adrian Janssen
Hmm, so if you put the log4j jar in the server/lib directory, then it will
get loaded by Tomcat's classloader and use that classloader's classpath?

-Original Message-
From: Wendy Smoak [mailto:[EMAIL PROTECTED]
Sent: 17 November 2003 15:34
To: Log4J Users List
Subject: RE: Revamp: App-server independent log4j logging


 Log4j searches the whole classpath, so if I put a properties file in 
 classes, it is found indeed (this is what I've done as a workaround).
 The thing is, the classes directory in my webapp is also part of the 
 classpath, and it should have found the file there...

I don't think so.  There is more than one classloader involved, and so
more than one classpath.  For each webapp, Tomcat gathers up all the
necessary stuff from WEB-INF/classes and WEB-INF/lib plus anything in
'common' and that's the classpath for that particular webapp.

Tomcat itself, the server, has its own classpath.  That classloader
doesn't know or care about any of the webapps.  So I'm fairly certain
you have to put the .properties file in the 'server' section to match
the log4j.jar file in server/lib.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM  





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

RE: Revamp: App-server independent log4j logging

2003-11-17 Thread Wendy Smoak
Tom wrote:
 The problem is that when I specify the log4j debug parameter 
 to see why it isn't loaded, I'm not getting any output, unless 
 I place another log4j.jar in the server/lib.

I don't see why you would expect to get server debugging *without*
putting a log4j.jar and properties file under the 'server' directory
structure.  Webapp logging is separate from server logging.

Also take a look at this thread:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg08804.html

I didn't read carefully, but it sounds like Tomcat 4.1 looks in more
places for log4j.xml than for log4j.properties.  Maybe you're running
into the same thing.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM 






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Revamp: App-server independent log4j logging

2003-11-17 Thread Wendy Smoak
 If the one and only log4j.jar is in WEB-INF/lib, then putting
 log4j.properties in WEB-INF/classes should work.  
 WEB-INF/classes should
 automatically be part of the webapp's classpath, so log4j 
 should find it.

Wasn't the original question about *server* error logging, not webapp?

Reading it again, it's unclear, but when I saw the use of
-Dlog4j.debug=true, I assumed the OP was trying to get debug messages
from Tomcat itself, not from his webapp.

But looking at the subject line, I now suspect I was answering the wrong
question.  Sorry!

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Revamp: App-server independent log4j logging

2003-11-17 Thread Tom Eugelink
If the one and only log4j.jar is in WEB-INF/lib, then putting
log4j.properties in WEB-INF/classes should work.  WEB-INF/classes should
automatically be part of the webapp's classpath, so log4j should find it.
As though I.


Are you deploying as an EAR?  
Nope, it is a context pointing directly to my build directory, 
containing web-inf/lib  web-inf/classes


Is WEB-INF/classes in the system classpath? 
Good question. I'm in house hold mode rightnow (feed the baby and stuff, 
it's pas 18:00 here) now and have to get back to this.

Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Revamp: App-server independent log4j logging

2003-11-17 Thread Jacob Kjome
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Revamp: App-server independent log4j logging

2003-11-17 Thread Yu Xiang Xi (Maveo)
It's one of the most funny mail dialogues I have seen :)
Good Job, Jake!

BR
Xi Yuxiang
Nov. 18th, 2003

-Original Message-
From: Jacob Kjome [mailto:[EMAIL PROTECTED] 
Sent: 20031118 9:19
To: Log4J Users List
Subject: Re: Revamp: App-server independent log4j logging

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Revamp: App-server independent log4j logging

2003-11-17 Thread Tom Eugelink
- 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! Noo, 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]