0
votes

I am deploying my application as an ear archive in wildfly 13. The ear contains a war and an ejb. The ejb is used in different projects. I want to log the information from the war and the ejb into a single file to have the full context what happend in a single logfile.

I managed to log from the war via logback, but the logs from the ejb are not logged via logback.

My current setup:

  • In my ear-module I have a jboss-deployment-structure.xml in my ear file to exclude the logging subsystem
  • In my web-module the logback.xml is located in WEB-INF/classes
  • In my web-module I have the dependencies to logback-classic and slf4j
  • In my ejb-module I have a dependency to slf4j

Any suggestions?

1

1 Answers

1
votes

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.