rsyslog
Jul 04, 2009 - 06:19 PM
Professional Support
Custom written rsyslog.conf? Maintenance Contract?

rsyslog professional services



Donate!
Satisfied with rsyslog?

Donate and help keep
the project alive!

Rainer's Blog

Login




 


 Log in Problems?
 New User? Sign Up!

Online
There are 16 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

back

Log rotation with rsyslog

Written by Michael Meckelein

Situation

Your environment does not allow you to store tons of logs? You have limited disc space available for logging, for example you want to log to a 124 MB RAM usb stick? Or you do not want to keep all the logs for months, logs from the last days is sufficient? Think about log rotation.

Log rotation based on a fixed log size

This small but hopefully useful article will show you the way to keep your logs at a given size. The following sample is based on rsyslog illustrating a simple but effective log rotation with a maximum size condition.

Use Output Channels for fixed-length syslog files

Lets assume you do not want to spend more than 100 MB hard disc space for you logs. With rsyslog you can configure Output Channels to achieve this. Putting the following directive

# start log rotation via outchannel
# outchannel definiation
$outchannel log_rotation,/var/log/log_rotation.log, 52428800,/home/me/./log_rotation_script 
#  activate the channel and log everything to it 
*.* $log_rotation
# end log rotation via outchannel

to ryslog.conf instruct rsyslog to log everything to the destination file '/var/log/log_rotation.log' until the give file size of 50 MB is reached. If the max file size is reached it will perform an action. In our case it executes the script /home/me/log_rotation_script which contains a single command:

mv -f /var/log/log_rotation.log /var/log/log_rotation.log.1

This moves the original log to a kind of backup log file. After the action was successfully performed rsyslog creates a new /var/log/log_rotation.log file and fill it up with new logs. So the latest logs are always in log_roatation.log.

Conclusion

With this approach two files for logging are used, each with a maximum size of 50 MB. So we can say we have successfully configured a log rotation which satisfies our requirement. We keep the logs at a fixed-size level of100 MB.

[manual index] [rsyslog.conf] [rsyslog site]

This documentation is part of the rsyslog project.
Copyright © 2008 by Rainer Gerhards and Adiscon. Released under the GNU GPL version 2 or higher.



Only logged in users are allowed to comment. register/log in
Back to the start page
 rsyslog Sponsors
 
Functionality looking for Sponsors
rsyslog sponsoring
Click here for more information


 Search
 
Google

 Last Forum Posts
 · Re: Rhel 5.3 x64
I don't know about the various distros, but I know that a couple ...
· Re: Rhel 5.3 x64
I was having the same problem...after poking around,Looks like rh ...
· Re: TLS stops sending messages
It should be sufficient to remove the gtls driver directive. Then ...
· Re: fromhost property is not resolved wi ...
I think this is currently not possible, at least not without code ...
· fromhost property is not resolved with r ...
Hi,we are currently using udp for sending logs from rsyslog clien ...
· TLS stops sending messages
Hi folks,After a period of time, rsyslog either stops receiving ( ...
· Re: Rhel 5.3 x64
This looks like the software got installed to the wrong pathes an ...
· Re: stop remote messages being written t ...
Hi, I am having the same issue. Here are the contents of /etc/rs ...

:: Syndication: ::
Page created in 0.192047834396 seconds.