views:

332

answers:

1

I have few web applications run on the Tomcat server. Each application contains its own log4j library copy inside its own war. This allows for separate, flexible logging configuration per application.

I also have few shared libraries (kept in Tomcat's shared libraries directory). I would like to have shared library loggers output among with the application (which uses them) loggers output (for example: if application A logs to file a.log, and uses library b.jar, I would like b.jar to log also to the a.log file). The problem is, that the shared libraries are loaded by the shared classloader, which causes that they can't access loggers defined by the applications. Is there any solution for this issue?

+1  A: 

You can look at SL4J bridging. You can configure an application to re-route calls to log4j to sl4j, and then you can do what you like with them, you can configure them to come out in the same file, or whatever.

There is a good article here as well: Thoughts on Java logging and SLF4J

MatthieuF