Two log4j files for an EAR with two modules

I have an EAR consisting of two modules. Both provide services and use a common code. Imagine that the ear has common.jar, shared by webservices.war and webapp.war.

I use log4j to log actions. I would like to be able to have two log files (webservices.log and webapp.log), recording events that are specific to each of them, and all the materials processed by common.jar.

How do I configure my categories and my applications to achieve this?

Currently I have the following packages:
com.myapp for sharing
com.myapp.webservices for web services and
com.myapp.webapp for webapp.

My problem is that I do not know how I can capture com.myapp (common stuff) in both log files using a single log4j configuration file. I tried to configure several configuration files, but when JBoss works fine, Websphere will break, and vice versa ...

thank

0
source share
1 answer

You can save the log4j configuration anywhere, just make sure Logger can initialize the engine from the configuration file. I see no reason why a single configuration file does not work for both Jboss and WebSphere. Could you clarify what violates?

You need to configure two application files named webservices and webapp in the same log4j configuration files and use package names to redirect to the corresponding application.

< logger name= "com.myapp.webservices" >
 < appender-ref ref = "webservices" /" >
</logger>

< logger name= "com.myapp.webapp" >
 < appender-ref ref = "webapp" /" >
</logger>

0

All Articles