0

I would like to log anything related to Spring security (4.2.16) with Log4j.

It is an EAR file deployed in Wildfly 10.1.0 with the log4j.xml deployed into WEB-INF/classes of a WAR file included in the EAR

log4.xml has the following category:

<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
    <param name="Threshold" value="debug" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern"
               value="%d{HH:mm:ss} %p [%t]:%c{3}.%M()%L - %m%n" />
    </layout>
</appender>

<category name="org.springframework.security" additivity="false">
    <priority value="TRACE" />
    <appender-ref ref="STDOUT"/>
</category>

Logs are printed for any of the project classes, but the Log4j configuration is not working for spring security.

After debugging, logger.isDebugEnabled() returns false in the AffirmativeBased class

How to get the logs for anything related to spring security?

kandan
  • 715
  • 2
  • 12
  • 39

1 Answers1

0

It seems (from what I have tested) that logging of third-party dependencies (at least, Spring) is not configured with the project's log4.xml but within Wildfly's logging subsystem.

I have added the lines below to the standalone-full.xml (inside the logging subsystem definition) and it is logging now:

<logger category="org.springframework.security">
  <level name="TRACE"/>
  <handlers>
    <handler name="CONSOLE"/>
  </handlers>
</logger>

I have not tried, but may work (and is as a better solution) to indicate in the EAR's jboss-deployment-structure.xml that the application excludes Wildfly's own logging subsystem and relies all logging (including third-party dependencies) to log4j. See Override logging in WildFly.

kandan
  • 715
  • 2
  • 12
  • 39