开发者

two log4j files for EAR with two modules

开发者 https://www.devze.com 2022-12-12 13:32 出处:网络
I have an EAR that is made up of two modules. Both expose services and share common code. Imagine that the ear has a common.jar shared by a webservices.war and webapp.war.

I have an EAR that is made up of two modules. Both expose services and share common code. Imagine that the ear has a common.jar shared by a webservices.war and webapp.war.

I use log4j to log the activities. I would like to be able to have two log files (webservices.log and webapp.log) capturing the events that are specific to each of them plus all the stuff that is handled by the common.jar.

How should I configure my categories and my appenders to achieve this?

At the moment I have the following packages:

com.myapp for shared stuff

com.myapp.webservices for the webservices and

com.myapp.webapp for the webapp.

My problem is that I don't know how I can capture the com.myapp (common stuff) in both log files by using a single log4j configuration file. I have tried setting up multiple configuration files but when JBoss would work OK Websphere would break and the other way round...

Than开发者_开发问答k you


You can keep log4j configuration anywhere you like, just make sure Logger is able to initialize the engine from the configuration file. I don't see any reason why one configuration file is not working for both Jboss and WebSphere. Could you be more specific on what is breaking?

You need to configure two file appenders named webservices and webapp in same log4j configuration files and using the package names redirect to the relevant appender.

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号