两个模块的EAR的两个log4j文件 [英] two log4j files for EAR with two modules

查看:167
本文介绍了两个模块的EAR的两个log4j文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由两个模块组成的EAR。两者都公开服务并共享公共代码。
想象一下,ear具有webservices.war和webapp.war共享的common.jar。

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.

我使用log4j来记录活动。我希望能够有两个日志文件(webservices.log和webapp.log)捕获特定于每个事件的事件以及common.jar处理的所有内容。

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.

我应该如何配置我的类别和我的appender来实现这个目标?

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

目前我有以下套餐:

com.myapp用于共享内容

com.myapp.webservices用于webservices和

com.myapp.webapp用于webapp。

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.

我的问题是我不知道如何使用单个log4j配置文件捕获两个日志文件中的com.myapp(常见内容)。
我已经尝试设置多个配置文件,但是当JBoss工作正常时,Websphere会中断,反之亦然...

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...

谢谢

推荐答案

您可以随时随地保持log4j配置,只需确保Logger能够从配置文件初始化引擎。我没有看到为什么一个配置文件不适用于Jboss和WebSphere的任何原因。你能更具体地说明什么是破坏吗?

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?

你需要在相同的log4j配置文件中配置两个名为webservices和webapp的文件追加器,并使用包名重定向到相关的appender。

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/> < br>
< / logger>

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

< logger name =com.myapp.webapp>

< appender- ref ref =webapp/>

< / logger>

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

这篇关于两个模块的EAR的两个log4j文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆