To Enable Server.log rotation in JBoss EAP 7.0 Standalone Mode.
Step 1:
Take a backup the standalone.xml file.
Step 2:
Comment the periodic-rotating-file-handler which is already existing in standalone.xml file and add the below custom handler in order to rotate the server.log based on size
<subsystem xmlns="urn:jboss:domain:logging:1.2">
<custom-handler name="filehandler" <!-- Add from this line -->
class="org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler"
module="org.jboss.logmanager">
<formatter>
<pattern-formatter
pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<properties>
<property name="maxBackupIndex" value="20"/>
<property name="rotateSize"
value="1048576"/> <!-- 100MB -->
<property name="suffix" value=".yyyy-MM-dd"/>
<property name="fileName"
value="${jboss.server.log.dir}/server.log"/>
</properties>
</custom-handler> <!-- Upto this line -->
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN"/>
</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="filehandler"/> <!-- Add this line in the root-logger -->
</handlers>
</root-logger>
</subsystem>
Step 1:
Take a backup the standalone.xml file.
Step 2:
Comment the periodic-rotating-file-handler which is already existing in standalone.xml file and add the below custom handler in order to rotate the server.log based on size
<subsystem xmlns="urn:jboss:domain:logging:1.2">
<custom-handler name="filehandler" <!-- Add from this line -->
class="org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler"
module="org.jboss.logmanager">
<formatter>
<pattern-formatter
pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<properties>
<property name="maxBackupIndex" value="20"/>
<property name="rotateSize"
value="1048576"/> <!-- 100MB -->
<property name="suffix" value=".yyyy-MM-dd"/>
<property name="fileName"
value="${jboss.server.log.dir}/server.log"/>
</properties>
</custom-handler> <!-- Upto this line -->
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN"/>
</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="filehandler"/> <!-- Add this line in the root-logger -->
</handlers>
</root-logger>
</subsystem>