logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Okara <billok...@gmail.com>
Subject Re: is it possible to set container shared lib to use custom loggerContext
Date Mon, 25 Jul 2016 18:56:55 GMT
Hi Remko,

thanks for the suggestion, that's actually what I am doing currently.
That is, listing the various class packages in the shared libs to be
logged to a common log file.

But was trying to see if there's some more robust way to do that,
something like (maybe) specify/config which loggerContext the
parentClassloader should be assigned to?

A common use case for that is, usually the JNDI resources will be put
in the container shared lib dir (as per tomcat's instruction), so
would be good if can config the container shared lib classloader
(parent of the webapp classloader) to use a logger context other than
the webapp logger context.

Comment?


Thanks!
William


On Mon, Jul 25, 2016 at 8:21 AM, Remko Popma <remko.popma@gmail.com> wrote:
> There may be other ways to do this, but if the classes in the sharedLib are
> in a specific package, you could configure the log4j2.xml configurations
> for both web apps to create a separate appender (and a separate log file)
> for the loggers for that package.
>
> Remko
>
> On Sat, Jul 23, 2016 at 3:18 AM, Bill Okara <billokara@gmail.com> wrote:
>
>> Hi,
>>
>> Following is my deployment env:
>>
>> tomcat7
>>     |- lib/sharedLib12.jar   // shared lib  used by webapp1 and webapp2
>>     |- lib/slf4j-api-1.7.7.jar, log4j-api-2.3.jar, log4j-core-2.3.jar,
>> log4j-slf4j-impl-2.3.jar
>>     |
>>     |- webapps
>>          |-webapp1/WEB-INF/classes/log4j2.xml
>>          |                                 lib/log4j-web-2.3.jar
>>          |-webapp2/WEB-INF/classes/log4j2.xml
>>          |                                 lib/log4j-web-2.3.jar
>>
>>
>>  With servlet 3.0+ and default ClassLoaderContextSelector, it was
>> quite simple (awesome!) to config so that log output from each webapp
>> will be sent to it's own log file (webapp1.log, webapp2.log)
>>
>> But the problem is that log output from the sharedLib jar will always
>> goto to the first loaded webapp, because:
>> ----------> Parent Classloader:
>> org.apache.catalina.loader.StandardClassLoader@59717824
>>
>> the parent classloader (the one sharedLib is loaded) will be assigned
>> to the loggerContext of the first loaded webapp (which kinda makes
>> sense).
>>
>>
>> Question:
>> is there a way to config so that jars inside the tomcat/lib can be
>> logged to a common/separate logger context (or log file) that is
>> independent of the loaded webapp? (without configure tomcat to use
>> log4j2 as internal logger?)
>>
>>
>> Thanks!
>> Bill
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>

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


Mime
View raw message