Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete old JBoss logs?

I'm using JBoss 7.1.3 on Mac 10.9.1. This is a development machine. How do I delete old server logs that appear under the

$JBOSS_HOME/standalone/log

directory? Ideally, I'd like logs older than 4 days to be deleted from my system, freeing up disk space.

like image 581
Dave Avatar asked Oct 21 '22 10:10

Dave


1 Answers

I am not sure whether you can auto delete files based on time lines of 4 days, the

<periodic-rotating-file-handler> 

does not have the provision to do so. However since your requirement is to free the disk space you can achieve that by using your config file (standalone or domain.xml).

By default the config file logging setting comes with periodic-rotating-file setting which looks like:

       <periodic-rotating-file-handler name="FILE" autoflush="true">
            <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>

Please change it to size-rotating-file-handler and define the log size(rotate-size) that you would want to maintain and the number of files(max-backup-index) by doing this you have fixed the size of your log directory and always rotate within the given size allocations.

       <size-rotating-file-handler name="FILE" autoflush="true" >
            <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"/>
            <append value="true"/> 
            <rotate-size value="10000K"/>
        <max-backup-index value="3"/>
        </size-rotating-file-handler>

Note that suffix does not work with <size-rotating-file-handler> For more info

like image 119
amitsalyan Avatar answered Oct 23 '22 15:10

amitsalyan