• Post Reply Bookmark Topic Watch Topic
  • New Topic

log4j with with multiple web apps?  RSS feed

 
Ivan Jouikov
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!

I am running resin-3.0.7 and I am using latest log4j version. Everything was fine running log4j when I had only 1 application on my server - siblumber.com. Log4j was setup up like this - /WEB-INF/log4j.xml which uses ${user.dir}/WEB-INF/logs/logname.txt in all its appenders.

Everthing was fine up until I deployed a new application - royaleskincare.com. It uses the EXACT same approach as siblumber.com, and here's what happens:

1. Server is started up
2. application royaleskicare.com is started up
3. its event listener configures log4j using DOMConfigurator
4. it writes a single line into royaleskincare.com/.../trace.txt
(everything's fine so far)
5. application siblumber.com is started up
6. its event listener configures log4j using DOMConfigurator
7. it writes a single line into siblumber.com/.../trace.txt

After the server is finished starting up, I check all my loggers, and it turns out that BOTH royaleskincare.com AND siblumber.com loggers point to "siblumber.com/.../logs/logname.txt"

It seems that when the second application starts up, it re-configures log4j for the first application. But how is it possible? Aren't web apps ran in separate JVMs? Even if I check System.getProperty("user.dir"), they point to their approporiate directories.

So does log4j uses some kind of JVM-independent external configuration file that causes it to mess up my first application?

Any help is appreciated, thanks in advance!

[ subject edited -ds ]
[ September 26, 2004: Message edited by: Dirk Schreckmann ]
 
sasi Madana
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check that where r u keeping ur LOG4J.jar , if ur keeping in WEB-INF/lib
directory, it is applicable to specfic application only.In ur case may be u r keeping ur LOG4J.jar file in commons dir.
 
Ivan Jouikov
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no I'm keeping it in the global /lib

so you're suggesting that I move it to app-specific directory?

But that doesn't sound right! I mean it doesn't matter where the jar comes from, it's the JVM that matters, right?
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that Log4J reads in some configuration file only once ... when it is loaded by the classloader. If you have multiple classloaders (i.e. one per web application), then it will be loaded multiple times, etc. So, Resin should have some classloading policy exactly for this. Check out its documentation. I went through the same thing with JBoss back in the day.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!