Java System Logger on Wildfly

308 views
Skip to first unread message

Claudio Weiler

unread,
May 3, 2022, 12:35:43 PM5/3/22
to WildFly
Hi,


It's more like a facade, without real logging implementation, but relying on existent logging framework.

We can use this API on Wildfly (with JDK 11), but it falls back to Java Util Logging, outputting levels as severe, fine, etc.

So, I would like to change this, so Java System Logger binds to JBoss Logging Framework (default on Wildfly). Anyone knows how to do this?

Thanks!

Claudio Weiler

unread,
May 3, 2022, 4:36:16 PM5/3/22
to WildFly
I see that WF has a LogManager lib that should handle this (jboss-logmanager-1.1.18.Final.jar): https://github.com/jboss-logging/jboss-logmanager/blob/2.1.18.Final/src/main/resources/META-INF/services/java.lang.System%24LoggerFinder

But it appears that this LogManager is not loaded. I found some posts about settings some system properties (-D flags) and changing the classload, but it seams a hack. Didn't found any source in official documentations.

Any clues?

Chris H

unread,
May 4, 2022, 6:55:14 AM5/4/22
to WildFly
Wildfly comes witha loggin implementation that works much like you'd expect with Log4J. Just use this import to access it.

import org.jboss.logging.Logger;

Claudio Weiler

unread,
May 4, 2022, 12:07:53 PM5/4/22
to WildFly
Thanks, but Java System Logger comes to solve an old problem in Java libraries: no unnecessary dependencies.

I want to build a library that do not depend on any logging framework, and uses what is available on environment. IMHO it's terrifying to add some libraries in my project, and get undesired surprises with references to log4j, slf4j, logback, tinylog, etc., especially in the current times, when one of this unnecessary dependencies got vulnerabilities.

Claudio Weiler

unread,
May 4, 2022, 12:42:58 PM5/4/22
to WildFly
Documentation on LoggerFinder says that:
"A logger finder is a concrete implementation of this class that has a zero-argument constructor and implements the abstract methods defined by this class. The loggers returned from a logger finder are capable of routing log messages to the logging backend this provider supports. A given invocation of the Java Runtime maintains a single system-wide LoggerFinder instance that is loaded as follows:
First it finds any custom LoggerFinder provider using the ServiceLoader facility with the system class loader.
"

So, I think that org.jboss.logmanager is not loaded on system class loader. How can I add org.jboss.logmanager to system class loader, and, it's safe to do this?

Thanks!

Chris H

unread,
May 5, 2022, 9:49:35 AM5/5/22
to WildFly
If youre using a POJ, you can get everything with this BOM import and its all provided by Wildfly.

<dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-jakartaee8-with-tools</artifactId>
                <version>${version.jboss.bom}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

Claudio Weiler

unread,
May 5, 2022, 12:25:24 PM5/5/22
to WildFly
So, I tried to follow some posts on Internet to enable org.jboss.logmanager, changing "-Djboss.modules.system.pkgs" (I don't know what it does), adding "-Djava.util.logging.manager" and adding "-Xbootclasspath/a:...". Tried multiple combinations of those startup parameters, but it always failed with error or not changing log level names. LogManager is a multi release jar, so maybe there is something related to it.

Then I build my own custom LoggerFinder implementation, much the same like JBoss LogManager, and tested it in Eclipse with success. In Eclipse I added my jar into classpath user entries of the WF run configuration. Now I need to know how to add this jar to WF system class path, I have tried  "-Xbootclasspath/a:..." parameter, but this works partially, my LoggerFinder is loaded, but log messages do not hit log handlers.

Thanks.

James Perkins

unread,
May 7, 2022, 12:10:23 PM5/7/22
to WildFly
I know at one point this worked. I don't recall if there was a change to the JDK internal LoggerFinderLoader which now uses the system class loader or if there was something that changed in JBoss Modules. I would imagine the only fix is to change something in JBoss Modules. However, it seems odd that the JDK would expect any log manager to be on the system class class loader. I'm not even sure what JBoss Modules could do here really.

Adding the log manager to the boot class path will just cause other issues really. It's possible, but requires more than just the log manager on there. Also, MR JAR's don't work on the boot class path so that would be why it doesn't appear to work there. 

Reply all
Reply to author
Forward
0 new messages