To manage the size of the files generated from activity logs and other system activity, it can be useful to delete past log files. For example, it's often useful to simply delete any log files after a set amount of time has passed, such as every month or quarter. This is done automatically with a utility called Logeraser, which is installed in the standard set of files and located in the <ROOT>/bin
directory.
The logeraser utility works by deleting, keeping, or compressing files based on the age of files in a given file set and the amount of free disk space you want. The utility automatically adds files to different file sets based on a default file mask, which is a method for finding and grouping files using a regular expression, or regex. You can define your own file mask, as well as how files are processed in each file set by defining parameters for file age and disk space.
Consider a file set You may also have another file set |
You do not need to manually run the utility to delete files, except to change the configuration settings. The utility automatically deletes any files that meet the configuration parameters. By default, log files in the default file sets are deleted after 30 days.
To configure Logeraser and change its default settings, you must have access to the file directory on the server. |
Each file set contains independent parameters that determine which files Logeraser deletes, keeps, and compresses:
black
: Files older than this age are deleted unconditionally.white
: Files younger than this age are kept unconditionally.zip
: Files older than this age are compressed, or zipped.Gray files are files older than the white
parameter but younger than the black
parameter. Logeraser deletes gray files in order from oldest to newest until a defined percentage of disk space is free. Two parameters define the the amount of disk space that affect gray files:
startthreshold
: Defines the amount of free disk space that must be unavailable before Logeraser begins deleting gray files. If you have more free disk space than is defined by this parameter, no gray files are deleted.finishthreshold
: Defines the amount of free disk space that must be available before Logeraser stops deleting gray files. When the free disk space reaches the amount defined by this parameter, the remaining gray files are kept. To configure Logeraser, go to the <ROOT>/bin
directory containing the utility and open it. The utility uses commands and parameters that you need to enter in the command line to change the utility's configuration. For a full list of commands and parameters, see Logeraser Reference at the end of this article.
The default settings for Logeraser are typically sufficient for most purposes. If you want to change the configuration, follow each section below in order.
Use the -i
command to print the current configuration. This shows you the directories, file masks, names, and parameters for all file sets.
server32b:/opt/server/AGILOFT_HOME # ./bin/logeraser -i Main parameters: Installation root : /opt/server/Agiloft Log file : /opt/server/Agiloft/logs/logeraser.log Start threshold : 50 Finish threshold : 55 File sets: name : wildflylogs Directory : /opt/server/Agiloft/wildfly/standalone/log File mask : .+\.log.* Process subdirs : false Delete older than : 30 days (Sat Feb 13 04:11:38 GMT+00:00 2010) Keep younger than : 7 days (Mon Mar 08 04:11:38 GMT+00:00 2010) Zip older than : 2 days (Sat Mar 13 04:11:38 GMT+00:00 2010) name : hprofs Directory : /opt/server/Agiloft/wildfly/bin File mask : .+\.hprof Process subdirs : false Delete older than : 30 days (Sat Feb 13 04:11:38 GMT+00:00 2010) Keep younger than : not set Zip older than : not set name : temps Directory : /opt/server/Agiloft/tmp File mask : .+ Process subdirs : true Delete older than : 30 days (Sat Feb 13 04:11:38 GMT+00:00 2010) Keep younger than : not set Zip older than : not set |
The configuration contains three file sets for processing:
/opt/server/Agiloft/wildfly/standalone/log
directory with .log
in their name..hprof
in the /opt/server/Agiloft/wildfly/bin
directory./opt/server/Agiloft/tmp
directory.These three file sets are standard and created automatically. In the example above, the root directory for files is |
Use the -F
command to reference a file set to edit its parameters. For example, to change the black
parameter from 30 days to 15 days for the wildflylogs
file set, as well as to display the resulting configuration, execute the following command:
server32b:/opt/server/Agiloft # ./bin/logeraser -F wildflylogs -B 15 -i |
The utility makes the specified change to the referenced file set and parameter, and the resulting configuration is printed because the -i
command is used:
server32b:/opt/server/Agiloft # ./bin/logeraser -F wildflylogs -B 15 -i Main parameters: Installation root : /opt/server/Agiloft Log file : /opt/server/Agiloft/logs/logeraser.log Start threshold : 50 Finish threshold : 55 File sets: name : wildflylogs Directory : /opt/server/Agiloft/wildfly/standalone/log File mask : .+\.log.* Process subdirs : false Delete older than : 15 days (Sun Feb 28 05:08:04 GMT+00:00 2010) Keep younger than : 7 days (Mon Mar 08 05:08:04 GMT+00:00 2010) Zip older than : 2 days (Sat Mar 13 05:08:04 GMT+00:00 2010) name : hprofs Directory : /opt/server/Agiloft/wildfly/bin File mask : .+\.hprof Process subdirs : false Delete older than : 30 days (Sat Feb 13 05:08:04 GMT+00:00 2010) Keep younger than : not set Zip older than : not set name : temps Directory : /opt/server/Agiloft/tmp File mask : .+ Process subdirs : true Delete older than : 30 days (Sat Feb 13 05:08:04 GMT+00:00 2010) Keep younger than : not set Zip older than : not set |
For each parameter you want to edit for a given file set, follow a similar process.
Use the -n
command to perform a "dry run" on the files and see which files are processed by the utility:
server32b:/opt/server/AGILOFT_HOME # ./bin/logeraser -F jbosslogs -n -r -v -c |
If the files are processed as you expect, remove the -n
command and run the utility to immediately remove the desired log files. In the future, log files meeting the configuration settings are automatically processed by the utility. You do not need to manually run Logeraser.
The log files from running Logeraser itself, such as what was processed and when, are stored in the |
The following list is a reference of all Logeraser commands and parameters. To see this list in Logeraser, run the utility without entering any options:
server32b:/opt/server/AGILOFT_HOME # ./bin/logeraser usage: Usage -B, black Black file age of the configured file set -D, directory Directory of the configured file set -E, before Insert new file set before named -F, fileset File set name for configuration -M, mask File name mask for the configured file set -R, remove Remove file set from configuration -S, subdirs Process sub-directories for the configured file set -T, finishthreshold Finish threshold value -W, white White file age of the configured file set -Z, zip Zip file age of the configured file set -c, console Output to console -i, info Print current configuration -n, dryrun Dry run (no files removed) -r, run Remove old log files -t, startthreshold Start threshold value -v, verbose Verbose output |
Related articles |