Search code examples
javaloggingwildfly-8jboss6.x

How to disable logging application logs in server.log file in Wildfly 8.2.0


I am migrating my application from JBoss 6 AS to Wildfly 8.2.0 AS. I could achieve creating application logs as expected but standalone/log/server.log file is also getting filled with application logs.I am using standalone-full-ha.xml configuration. Could anyone please suggest an option to disable application logs getting filled into server.log.

Below section is taken from standalone-full-ha.xml:

<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>

Solution

  • You can add an additional custom file handler to the logging subsystem for your application category or categories:

      <subsystem xmlns="urn:jboss:domain:logging:2.0">
        <console-handler name="CONSOLE">
            <level name="INFO"/>
            <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>
        <periodic-rotating-file-handler name="MYHANDLER" autoflush="true">
            <formatter>
                <named-formatter name="PATTERN"/>
            </formatter>
            <file relative-to="jboss.server.log.dir" path="application-audit.log"/>
            <suffix value=".yyyy-MM-dd"/>
            <append value="true"/>
        </periodic-rotating-file-handler>
        <logger category="com.mycompany.myapplication">
            <level name="INFO"/>
            <handlers>
                <handler name="MYHANDLER"/>
            </handlers>
        </logger>
    

    See also: How to log application auditing to separate file on Wildfly 8