Logs Vacuum Cleaner is a small and flexible (i.e. configurable) tool created to remove old log files, allowing you to keep them compressed in a single file and/or permanently remove them.
Generally, the Logs Vacuum Cleaner is applicable whenever:
- Your application(s) generates multiple log files and there isn't any post process to deal with them
- You want to be able to compress a set of log files using a compression algorithm of choice.
- You have more than one directory storing logs and you want a centralized way to purge them.
- You want to discard old, non-compressed files.
Getting right to the point, configurations are stored at ./config/vacuums.json dir. This is a complete configuration example:
{
"vacuums" : [
{
"path" : "/some/log/path/",
"filesPrefix" : "server*",
"filesSuffix" : "*.log",
"removeLogs" : true,
"compressor" : "tar.gz",
"outputPath" : "/some/backup/path/",
"outputName" : "logs.2006-01.tag.gz",
"updateOutput" : true
}
]
}
Where:
The Base path where the logs are stored. Required.
Files prefix. Accepts wildcard *. Under *nix systems you can specify more than one pattern using braces. Ex: {log-*,access-*,error-*} Not required.
Files suffix. Accepts wildcard *. Under *nix systems you can specify more than one pattern using braces. Ex: {*.log,*.txt,*.output} Not required.
Should the Vacuum remove found logs after merging and compress them? Not required.
Compression algorithm. Only tar.gz is supported at the moment. Required.
Output path where the compressed file will be stored. Required.
Output file name where the compressed file will be stored. Accepts Go Time format parameters. Required.
If the vacuum finds a previously generated output, should it just update the output file (by appending new log files) ? Not Required, default false.
To build a docker image, you should just simply type:
$ docker build --rm -t peixeurbano/logs-vacuum .
In order to run it, simply do:
$ docker run peixeurbano/logs-vacuum
Tests were write using Go testing. In order to run them, just type:
$ go test
Under scripts/ dir you can regenerate builds using generate-builds.sh script file. Currently, we are exporting LogsVacuum to the following systems/archs:
- linux/386
- linux/amd64
- linux/arm
- macos (darwin)/386
- macos (darwin)/amd64
- windows/386
- windows/amd64
The latest builds can be found at /dist dir.
MIT. Copyright (c) Peixeu Urbano.