Logrotate in Yate
Line 6: | Line 6: | ||
===Why use logrotate?=== | ===Why use logrotate?=== | ||
− | Logrotate is an application that runs as a daily cron job. It eases the management of system logs. You can compress, rotate,remove and email file logs of your system as well as for other processes. | + | Logrotate is an application that runs as a daily cron job. It eases the management of system logs.<br> |
− | + | You can compress, rotate,remove and email file logs of your system as well as for other processes. | |
===Prepare logs rotation=== | ===Prepare logs rotation=== | ||
Line 49: | Line 49: | ||
===How to use it?=== | ===How to use it?=== | ||
− | To use yate.logrotate, you must enable the rotate option when you start Yate as a service. | + | To use yate.logrotate, you must enable the rotate option when you start Yate as a service. <br> |
− | The -r option requires enabling the supervised mode and naming a log file. So run Yate including -s -r -l to the command “yate”. When running yate as a service with rotation enabled, you will find the log files in /var/log/yate. Otherwise, the log files are found in the build directory. For more information related to Yate's start command, type yate --help. | + | The -r option requires enabling the supervised mode and naming a log file. So run Yate including -s -r -l to the command “yate”.<br> |
+ | When running yate as a service with rotation enabled, you will find the log files in /var/log/yate. Otherwise, the log files are found in the build directory. For more information related to Yate's start command, type yate --help.<br> | ||
Revision as of 16:31, 15 January 2013
The file “yate.logrotate” is a configuration file that uses the same options and directives as UNIX's logrotate.
Just type “man logrotate” in the command line to convince yourself. If you decide that you want to take a look, you can find yate.logrotate in the packing/ subdirectory of Yate. When you install Yate as a service, the configuration file will be installed as /etc/logrotate.d/yate, along with the configuration files for all the other services and programs installed on your system.
Contents |
Why use logrotate?
Logrotate is an application that runs as a daily cron job. It eases the management of system logs.
You can compress, rotate,remove and email file logs of your system as well as for other processes.
Prepare logs rotation
Copy packing/yate.logrotate as /etc/logrotate.d/yate and optionally edit it to adjust the limits. Note that logrotate normally runs daily so make sure you collect signifficantly less than 2GB of logs in 24 hours.
You will also need to make the file owned by root:
cp packing/yate.logrotate /etc/logrotate.d/yate chown root.root /etc/logrotate.d/yate
If your logs grow too fast you have to either reduce the logging level - eventually per module - or set up logrotate to run more often. For example you can move the logrotate script from /etc/cron.daily to /etc/cron.hourly
How does it work?
The logrotate configuration file, etc/logrotate.conf, besides the usual options and directives, includes other configuration files found in /etc/logrotate.d. Various packages will install their own configuration file that ensures their logs are properly rotated. This also applies for yate.logrotate, which will rotate yate's log file.
Below you can see the content of the configuration file:
Content of /etc/logrotate.d/yate
# Have to rotate the log and CDR files before each reaches 2GB in size /var/log/yate /var/log/yate-cdr.tsv { size=100M rotate 5 missingok notifempty postrotate /bin/kill -HUP `/bin/cat /var/run/yate.pid` endscript }
File yate.logrotate handles the file yate and yate-cdr.tsv by rotating it each time its' size reaches 100 M.
Each day, yate.logrotate will compare the size of /var/log/yate with 100 M. If its' size is 100 M or bigger, the log file will be rotated.
The number of rotations is 5.
After a running period of time, yate.logrotate will start overwriting the rotated files. This measure is meant to prevent Yate's crush due to reaching of /var/log/yate to 2 GB in size.
You won't receive an error message if the log file is missing but the file will not be rotated if it is empty.
The command “kill -HUP” sends a SIGHUP signal to Yate's supervisor each time yate.logrotate has finished rotating the log file.
How to use it?
To use yate.logrotate, you must enable the rotate option when you start Yate as a service.
The -r option requires enabling the supervised mode and naming a log file. So run Yate including -s -r -l to the command “yate”.
When running yate as a service with rotation enabled, you will find the log files in /var/log/yate. Otherwise, the log files are found in the build directory. For more information related to Yate's start command, type yate --help.
See also