I search logger configuration in the web for Jboss 7
. How to configure logger using date and size together.
File Logger 1 size-rotating-file-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="1000k"/>
<max-backup-index value="20"/>
<append value="true"/>
</size-rotating-file-handler>
Out Put Files are :
server.log.1
server.log.2
server.log.3
..
File Logger 2 periodic-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>
Out Put Files are :
server.log.2013-12-12
server.log.2013-12-13
server.log.2013-12-14
..
My expected files are
server.log.2013-12-12.1
server.log.2013-12-12.2
server.log.2013-12-12.3
server.log.2013-12-13.1
server.log.2013-12-13.2
server.log.2013-12-13.3
Depending on your version of JBoss AS 7 there is a org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler
you can use as a custom-handler
. I believe it was introduced in jboss-logmanager 1.3.0.Final. I can't recall which version of JBoss AS/WildFly it is in though.
Here's an example CLI command.
/subsystem=logging/custom-handler=example:add(class=org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler, module=org.jboss.logmanager, formatter="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n", properties={rotateSize=1024000,maxBackupIndex=20,suffix=".yyyy-MM-dd",fileName="${jboss.server.log.dir}/example.log"})
Here's what worked for me (make sure to change the rotationSize and maxBackupIndex to whatever makes sense for you. The numbers I have in there are just for testing):
<custom-handler name="FILESIZEDATE" 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="autoFlush" value="true"/>
<property name="append" value="true"/>
<property name="rotateSize" value="1000"/>
<property name="maxBackupIndex" value="20"/>
<property name="suffix" value=".yyyy-MM-dd"/>
<property name="fileName" value="${jboss.server.log.dir}/server.log"/>
</properties>
</custom-handler>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="FILESIZEDATE"/>
<handler name="CONSOLE"/>
</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