Configure logback in Wildfly
Asked Answered
H

0

7

I have terrible problems to figure out how to configure logging via logback in my Java EE application on Wildfly 10. I tried to put slf4j-api-1.7.21.jar, logback-classic-1.1.7.jar and logback-core-1.1.7.jar in my ear in /lib/, add logback.xml to resources in my ejb module and add jboss-deployment-structure.xml into my ear META-INF. It almost works... Logback creates my log files and correctly log into them. Unfortunately logging to console works strange. It looks like wildfly concatenated default pattern with my pattern from logback configuration.

After that I tried to put logback as module into wildfly. I've added modules org.slf4j and ch.qos.logback. I've also made module org.jboss.logging depends of them. Configuration file (logback.xml) has been put into $JBOSS_HOME/standalone/configuration and -Dlogback.configurationFile=$JBOSS_HOME/standalone/configuration/logback.xml has been added to JAVA_OPTS. Unfortunately this work just the same.

I've tried to experiment with lots of combinations of two above approaches. I've tried different exclusions in jboss-deployment-structure.xml and different configurations of modules but none of them works. I pushed my sample project to github at https://github.com/mlewando/jboss-logback. I made two tags: LOGBACK_IN_APP for the first approach and LOGBACK_IN_SERVER for the second.

I'd really glad if someone has any idea what I'm doing wrong. I'm starting to have a little bit out of time with this. I've been doing googling and tries and errors for almost 4 days and it has to be working till Wednesday. I will very appreciate any help.

Update: Just after posting this question, I found some other question about the same situation: Logback + Wildfly 8 - incorrect pattern (as always, I find something right after posing my own question...). It gives some light on my problem, but didn't solve it. After following advice from answer that I found there, I end up with no logs in console at all.

Hulbert answered 22/5, 2016 at 16:52 Comment(1)
See Enable LogBack in JBoss by Leon on AnotheriaMaffei

© 2022 - 2024 — McMap. All rights reserved.