If you're just logging to a file you could use a logging-profile which would allow you to make runtime changes and not have to redploy your application if you want to make changes to your logging configuration.
Using WildFly Logging
Example Profile Configuration
/subsystem=logging/logging-profile=ear1:add
/subsystem=logging/logging-profile=ear1/pattern-formatter=PATTERN:add(pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n")
/subsystem=logging/logging-profile=ear1/periodic-rotating-file-handler=FILE:add(append=true, suffix=".yyyy-MM-dd", named-formatter=PATTERN, file={relative-to=jboss.server.log.dir, path="ear1.log"})
/subsystem=logging/logging-profile=ear1/root-logger=ROOT:add(level=INFO, handlers=[FILE])
Then you'd just add Logging-Profile: ear1
entry in your EAR's manifest.
Using Logback
If you want to continue using logback you'd need to put the logback and slf4j dependencies in your EAR/lib
directory. The trick will be figuring out where to put the logback configuration file. It might work in EAR/META-INF
or in the EAR/lib
, but I'm not certain. It may even work if you kept it in the WAR/WEB-INF/classes
, but you'd need to ensure a logger is accessed in the WAR before one is accessed in the EJB.
You'll also want to ensure you exclude the org.slf4j.api
module or the logging
subsystem for the EAR and each subdeloyment in your jboss-deployment-structure.xml
.