[英]Separate logging across different EE components (REST / EJB)
我的目的是在JEE 5 Web應用程序(JBoss 5.1)中在REST和EJB之間分離log4j配置。
對於REST模塊,我使用ServletContextListener
接口:
public void contextInitialized(ServletContextEvent sce) {
PropertyConfigurator.configure("logfile");
}
對於EJB模塊,我正在使用StartupBeanManagement
接口:
@Override
public void start() throws Exception {
logger.info("starting configuration bean");
final String env = System.getProperty("env");
configureLog(logFilePrefix.replace("{0}", env));
}
但是,如果兩個模塊都部署在同一容器上,則只能看到專用REST日志上的日志。
如何區分模塊之間的日志記錄?
Log4J在類加載器級別保留其配置。 如果兩個JEE模塊共享一個類加載器,則它們將在運行時具有單個Log4J配置。
為了分開模塊之間的日志記錄,您需要:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.