Quoting Fabrizio Squittieri <[EMAIL PROTECTED]>:

> So if i have a log4j.jar in any webapp i can say that their log4j.properties
> are completely independent?
>
> And i shouldn't mind if someone puts a log4j.rootLogger=DEBUG,stdout
> somewhere in any log4j.properties?
>
> I don't know but it seems to me the opposite, i mean few months ago we
> deployed a web app which was bought from another software house; they used
> log4j configuring it as above (root logger at DEBUG level...), the result was
> an impressing amount of logging statements...and they did have a log4j.jar
> under their lib...
>

Where did they put log4j.properties?  Was it in the WebappClassLoader classpath
such as WEB-INF/classes?  If not, then Log4j will search for the properties
file further up the classloader hierarchy.  You need two things:

1.  log4j.properties (or log4j.xml) in WEB-INF/classes
2.  log4j.jar in WEB-INF/lib

And, just to be clear, this applies to Tomcat standalone version.  If you use
Tomcat under JBOSS or something like that, then all this advice can be thrown
out the window, because that changes the game entirely.

BTW, Log4j tries to load log4j.xml in preference to log4j.properties.  I haven't
tested this, but I could imagine a case where log4j.properties is in
WEB-INF/classes and log4j.xml is in Tomcat's common/classes and the log4j.xml
gets loaded rather than the properties file as a side-effect of the
preferential treatment of log4j.xml.  You could look into that.  I always use
log4j.xml, so never have that issue anyway.

One other thing you might look into is to make sure that the log4j.jar in
Tomcat's common/lib has a corresponding config file to load.  Log4j loads the
config file via the context classloader.  This means that if you don't provide
a config file in common/classes, it will look for one elsewhere in order to
perform auto-configuration on the default logger repository.  This could be
what is happening in your case.  To fix this, put a Log4j config file in
common/classes which is the default config file for the server.


Jake

> FS
>
> -----Messaggio originale-----
> Da: Jacob Kjome [mailto:[EMAIL PROTECTED]
> Inviato: venerdì 26 agosto 2005 16.29
> A: Log4J Users List
> Oggetto: Re: Multiple log4j.properties
>
> Quoting Fabrizio Squittieri <[EMAIL PROTECTED]>:
>
> > Hi,
> > i've got a simple question.
> > We have a Tomcat 5.0.5 on A linux server which runs a number of web
> > apps.
> >
> > Now we wanted to configure log4j in a single file and we did it by
> > adding a
> >       -Dlog4j.configuration=file:/usr1/config_tmp/log/log4j.properties
> > \ row to catalina.sh .
> >
> > The question is: What does it happen if a web-app puts a
> > log4j.properties (e.g.log4j.rootLogger=DEBUG,stdout or some other bad
> > configs) in its WEB-INF/classes?
> >
> > Does it overwrite the global config?
> >
>
> No, it won't overwrite the global config as long as a copy of log4j.jar is
> included in the webapp.  It will use its own configuration and be completely
> separated from the global logger repository.  This is because of Tomcat's
> default parent-last classloading behavior (recommended by the servlet spec).
> If you had parent-first classloading behavior, which is usually the default
> in most larger application servers, then you would have a problem.
>
>
> Jake
>
> > Thanks
> >
> > Fabrizio Squittieri - Programmatore
> >
> > Sistema informativo - Comune di Prato
> > Via Cairoli 16 - Prato
> > 0574615275
> >
> > [EMAIL PROTECTED]
> > [EMAIL PROTECTED]
> >
> >
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> 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]
>




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

Reply via email to