Skip to main content

JBOSS7 Logging with Size Rotating

To change jboss7 log rotating from periodic to size base, comment periodic-rotating-file-handler and insert the following size-rotating-file-handler into standalone.xml

<profile>
<subsystem xmlns="urn:jboss:domain:logging:1.1">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
</console-handler>

<size-rotating-file-handler name="FILE">
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<rotate-size value="20480k"/>
<max-backup-index value="20"/>
<append value="true"/>
</size-rotating-file-handler>

<!--
<periodic-rotating-file-handler name="FILE">
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
-->

Comments

  1. very easy and it works
    thank you !

    ReplyDelete
  2. Hi. Its not working if custom handler is used. Please let me know if adding rotate code in the custom handler code is the only way or there is something easier!

    ReplyDelete
  3. If you wrote custom handler then you have to add your custom handler's name to the root-logger as well.
    <root-logger>
    <level name="DEBUG"/>
    <handlers>
    <handler name="CONSOLE"/>
    <handler name="FILE"/>
    <handler name="Your Custom Handler's Name Here"/>
    </handlers>
    </root-logger>

    ReplyDelete

Post a Comment

Popular posts from this blog