Our application runs in WildFly, but we use custom logging, so in jboss-deployment-structure.xml
there are these lines:
<exclude-subsystems>
<subsystem name="logging"/>
</exclude-subsystems>
We use SLF4j with Logback backend, so project dependencies (in Gradle format) include these:
compile 'org.slf4j:slf4j-api:1.7.12'
compile 'ch.qos.logback:logback-classic:1.1.3'
compile 'org.slf4j:jcl-over-slf4j:1.7.12'
Recently I added another library that uses java.util.logging
and not SLF4j, so its logs would just go to stdout. To solve this, I added another dependency:
compile 'org.slf4j:jul-to-slf4j:1.7.12'
and added the following two lines of Java code to the application initialization code:
SLF4JBridgeHandler.removeHandlersForRootLogger ();
SLF4JBridgeHandler.install ();
Now that library also logs fine.
But, another problem appeared: now WildFly messages are also written into our log (seems it also uses java.util.logging). This is not so bad as it is (even if we prefer application and webserver logs to be separated), but they come along non-formatted, with unconverted placeholders. E.g. before jul-to-slf4j
addition WildFly would log this message:
[...] UT005023: Exception handling request to /Main.html
but now I instead see this:
[...] UT005023: Exception handling request to %s
Do I need to add some extra configuration so that jul-to-slf4j
can properly format messages? Or is there some fundamental limitation with handling messages with parameters?
Hmmm... it looks like Wildfly (certainly version 8+) uses JBoss logging. Jboss logging as far as I can tell is another logging wrapper.
It must be configured to push on to JUL.
From my reading of the source code it looks like it supports pushing onto slf4j as well...
So you should investigate how to tell Jboss logging in wildfly to log to slf4j.