Search code examples
springloggingwildfly

Get spring framework logging in wildfly


I was trying to get Spring 4 to log in Wildfly 8.2. I wanted spring to use the wildfly logging configuration.

All the examples I could find were trying to complicate this process by adding additional logging frameworks and configuration.

So here is how I did it, for prosperity.


Solution

  • To get spring 4 to log in wildfly 8, I had to add the following to the logging subsystem config in the standalone.xml file.

    <add-logging-api-dependencies value="false"/>
    <use-deployment-logging-config value="false"/>
    

    Additionally to get debug logging

    <logger category="org.springframework">
                    <level name="DEBUG"/>
    </logger>
    

    Here is the full subsystem config:

        <subsystem xmlns="urn:jboss:domain:logging:2.0">
                <add-logging-api-dependencies value="false"/>
                <use-deployment-logging-config value="false"/>
                <console-handler name="CONSOLE">
                    <level name="DEBUG"/>
                    <formatter>
                        <named-formatter name="COLOR-PATTERN"/>
                    </formatter>
                </console-handler>
                <periodic-rotating-file-handler name="FILE" autoflush="true">
                    <formatter>
                        <named-formatter name="PATTERN"/>
                    </formatter>
                    <file relative-to="jboss.server.log.dir" path="server.log"/>
                    <suffix value=".yyyy-MM-dd"/>
                    <append value="true"/>
                </periodic-rotating-file-handler>
                <logger category="com.arjuna">
                    <level name="WARN"/>
                </logger>
                <logger category="org.apache.tomcat.util.modeler">
                    <level name="WARN"/>
                </logger>
                <logger category="org.springframework">
                    <level name="DEBUG"/>
                </logger>
                <logger category="org.jboss.as.config">
                    <level name="DEBUG"/>
                </logger>
                <logger category="sun.rmi">
                    <level name="WARN"/>
                </logger>
                <logger category="jacorb">
                    <level name="WARN"/>
                </logger>
                <logger category="jacorb.config">
                    <level name="ERROR"/>
                </logger>
                <root-logger>
                    <level name="INFO"/>
                    <handlers>
                        <handler name="CONSOLE"/>
                        <handler name="FILE"/>
                    </handlers>
                </root-logger>
                <formatter name="PATTERN">
                    <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                </formatter>
                <formatter name="COLOR-PATTERN">
                    <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                </formatter>
            </subsystem>