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?
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
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 inEAR/META-INF
or in theEAR/lib
, but I'm not certain. It may even work if you kept it in theWAR/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 thelogging
subsystem for the EAR and each subdeloyment in yourjboss-deployment-structure.xml
.