Can't see console logs with log4j and Wildfly 24.0.1

1,736 views
Skip to first unread message

Manuel Migueles

unread,
Jul 11, 2022, 4:15:07 PM7/11/22
to WildFly
Greetings!

I am experiencing a strange condition when deploying my project on Wildfly 24.0.1. I have already tried to find an answer in all the blogs and pages that I have been able to without success so far. I am writing to this group in the hope that someone knows why this happens:

I add the .ear of my project to the server with the following configuration in the jboss-deployment-structure.xml file:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="logging"/>
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>


...and a very basic log4j configuration file (asplog4j.xml):

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug">
<Properties>
<Property name="LOG_PATTERN">%d{yyy-MM-dd'T'HH:mm:ss.SSS} %p %m%n</Property>
</Properties>
<Appenders>
<Console name="LogToConsole" target="SYSTEM_OUT" follow="true">
<PatternLayout pattern="${LOG_PATTERN}"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="LogToConsole">
</Root>
</Loggers>
</Configuration>


Then, while deploying in the console log I see messages like:

Reconfiguration complete for context[name=1ae1119] at URI vfs:/C:/Dev/wildfly-24.0.1.Final/bin/content/asp2.ear/properties.jar/asplog4j.xml (org.apache.logging.log4j .core.LoggerContext@1a20289) with optional ClassLoader: null

And almost when finishing deploying the .ear, it shows a message in the console log that says:

Reconfiguration complete for context[name=153d4ef] at URI NULL_SOURCE (org.apache.logging.log4j.core.LoggerContext@10113d) with optional ClassLoader: null

Then, when I put breakpoints in the code and I see the execution in debug mode, I realize that all the loggers with the 1ae1119 context are shown in the console log, but the loggers with the 153d4ef context are not shown. And it does not help me that some logs are seen and others are not. I imagine that the ones that are not seen is because they are associated with the context that has the URI NULL_SOURCE. But I don't know how to fix this.

Does anyone know how?

Thanks in advance for any assistance.

James Perkins

unread,
Jul 12, 2022, 10:39:38 AM7/12/22
to WildFly
You need to exclude the logging subsystem for your sub-deployments of your EAR as well, https://docs.wildfly.org/24/Developer_Guide.html#jboss-deployment-structure-file.

Manuel Migueles

unread,
Jul 12, 2022, 6:12:33 PM7/12/22
to WildFly
Hi! Thank you very much for your answer.

Do you mean that I must include a jboss-deployment-structure.xml file in the META-INF folder of each module that has content in my .EAR?

James Perkins

unread,
Jul 12, 2022, 6:17:25 PM7/12/22
to WildFly
No I mean you need to add exclusions for the logging subsystem on each sub-deployment. Like:
<jboss-deployment-structure>

  <deployment>
     <exclude-subsystems>
        <subsystem name="logging" />
    </exclude-subsystems>
  </deployment>
  <sub-deployment name="myapp.war">

     <exclude-subsystems>
        <subsystem name="logging" />
    </exclude-subsystems>
  </sub-deployment>
</jboss-deployment-structure>


Manuel Migueles

unread,
Jul 12, 2022, 6:47:58 PM7/12/22
to WildFly
Thanks again for your answer.

I did what you told me but now it shows less logs than before :(

James Perkins

unread,
Jul 12, 2022, 6:53:28 PM7/12/22
to WildFly
That is a good sign actually :) That means that there is something missing in your configuration. For example, how do you load your asplog4j.xml? You may just need to set a system property to tell log4j2 where the configuration is located, https://logging.apache.org/log4j/2.x/manual/configuration.html.

Manuel Migueles

unread,
Jul 12, 2022, 7:11:07 PM7/12/22
to WildFly
Do you mean to do from the cli something like this for example?

/system-property=log4j.configurationFile:add(value=${env.JBOSS_HOME}/standalone/configuration/asplog4j.xml)

But how to make that Wildfly not look for it in the /standalone/configuration/ folder but inside the .EAR deployed?

James Perkins

unread,
Jul 12, 2022, 7:48:50 PM7/12/22
to WildFly
You'd have to set it in the EAR before logging is configured or configure logging a different way. For example you could just name the file log4j2.xml and it should be automatically picked up if it's on the class path in the EAR.

Manuel Migueles

unread,
Jul 13, 2022, 11:17:48 AM7/13/22
to WildFly
Hi, James!

I did what you mentioned. I just put in the cli command the log4j2.xml file name located in the class path of my .EAR and it worked like a charm!

Thank you very much for your help!
Reply all
Reply to author
Forward
0 new messages