I have confusion in setting up the log in Wildfly-8.2.0. Initially I had used my own logging system, with log4j.xml built into the WAR file, all worked very well. But, when I make any changes to the log configuration I need to redeploy the app to make the changes effect. So, I switched to the JBoss logger sub system. The below is configuration I did to the standalone.xml
from the jboss-cli
/subsystem=logging/custom-handler=myplatform:add(class=org.apache.log4j.RollingFileAppender, module=org.jboss.log4j.logmanager, formatter="%d{.yyyy-MM-dd} %-5p [%c] (%t) %s%E%n", properties={MaxFileSize=1024000,maxBackupIndex=20,file="${jboss.server.log.dir}/myplatform-debug.log"})
so it added the below configuration in standalone.xml
<custom-handler name="example" class="org.apache.log4j.RollingFileAppender" module="org.jboss.log4j.logmanager">
<formatter>
<pattern-formatter pattern="%d{.yyyy-MM-dd} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<properties>
<property name="MaxFileSize" value="1024000"/>
<property name="maxBackupIndex" value="20"/>
<property name="file" value="${jboss.server.log.dir}/ott-platform-log.log"/>
</properties>
</custom-handler>
And then a logger for this
<logger category="com.mycompany.project.module1">
<level name="DEBUG"/>
<handlers>
<handler name="myplatform"/>
</handlers>
</logger>
All works well, but all my application logs are logged into the server log too. And, in the console log too. I don't want this to happen, after all I have configured the logger separately for my project! How do I stop the server log my logs logging into the server.log? Or is there a way to use an appender for this? If so how?
From the "clean" standalone.xml
I do the following:
<profile>
<subsystem xmlns="urn:jboss:domain:logging:2.0">
...
<console-handler name="CONSOLE_HANDLER">
<level name="DEBUG"/>
<formatter>
<named-formatter name="ECLIPSE_PATTERN"/>
</formatter>
</console-handler>
...
<profile>
<subsystem xmlns="urn:jboss:domain:logging:2.0">
...
<periodic-rotating-file-handler name="MI_PROJECT_FILE_HANDLER" autoflush="true">
<formatter>
<named-formatter name="ECLIPSE_PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="myProject.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
...
use-parent-handlers
<logger category="com.company.project" use-parent-handlers="false">
<level name="DEBUG"/>
<handlers>
<handler name="MI_PROJECT_FILE_HANDLER"/>
<handler name="CONSOLE_HANDLER"/>
</handlers>
</logger>
<formatter name="ECLIPSE_PATTERN">
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With