Rolled file issues with JBoss EAP 7 in Log4j2

Posted on

Hi,
I am working on the log4j2 migration for JBoss 7. But there are few issues on the migration.

Scenarios:
Previously, we included log4j v1 dependency in jboss-deployment-structure.xml, and also configure jboss logging subsystem in standalone.xml. It worked good.
Issue 1: In the migration, I exluded log4j v1 dependency and included log4j v2 dependencies (log4j-core & log4j-api & log4j-1.2-api) in jboss-deployment-structure.xml, and added in standalone.xml. Also, I added a log4j2.xml file.
But the logging.properties still got overwritten from standalone.xml, and we found that after a rolling policy triggerred, the log events will be appended in both the rolled file (app.log.2022-09-22) and the main file (app.log). Seems like it is related to the LoggerContext issue.
Issue 2: And then I tried to remove all settings inside the logging subsystem in standalone.xml.
After that, no rolling issue happend, but there are some log events missing in our logs, I think most of them are from jboss classes (like org.jboss.as.ejb3, org.jboss.ejb3.deployment, etc).

I tried to remove log4j2.xml file, but the log events are logged in an unexpected format because log4j2 will use DefaltConfiguration if it cannot find a config file.

Does anyone know how I can migrate log4j to log4j2 properly for JBoss app? Thanks!

Responses