My purpose is to separate log4j configuration between REST and EJB in a JEE 5 web application (JBoss 5.1).
For REST module, I use the ServletContextListener
interface:
public void contextInitialized(ServletContextEvent sce) {
PropertyConfigurator.configure("logfile");
}
for EJB module, I'm using the StartupBeanManagement
interface:
@Override
public void start() throws Exception {
logger.info("starting configuration bean");
final String env = System.getProperty("env");
configureLog(logFilePrefix.replace("{0}", env));
}
However, if both modules are deployed on the same container, I can see log only only on dedicated REST log.
How I can separate logging between modules?
Log4J holds its configuration at the classloader level. If two JEE modules share a classloader, they will have a single Log4J configuration at runtime.
In order to separate logging between modules, you need to:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.