This Howtos posted under: Apache | Total Visitors Till Now: 125

How to Rotate Apache logs using Awstats

Whatever web log analyzer you would use, at one time or the other you will end up with one problem: how to deal with weblogs rotation, to not have a gap in your statistics? This has various solutions starting with running the weblog analyzer at the prerotate step of logrotate, or maybe using some manual script.
This post will show how you can rotate the apache logs using awstats right after it has processed the logs. This can be beneficial for situations where you have quite big logs and using this method will keep them small all the time, and also where restarting apache just for logrotating is not such a good idea. Obviously for this to make sense, you need to be already using awstats for your log processing .

The awstats config option PurgeLogFile will purge the log file, after analyzing it. The default is 0 and this means no purge is done, and will assume some external tool is used for log rotation (like logrotate, or even apache internal mechanisms like rotatelogs). If this is set to 1, awstats will purge of the log file everytime it is run:
PurgeLogFile=1
By default the ‘archive’ file will be saved under: DirData/awstats_archive.configname.log , meaning this will become in time a huge file that needs to be also rotated, compressed, archived, etc. Another nice option of awstats is the possibility to rotate this file. ArchiveLogRecords can be used for this, and again this is also set by default on 0.
- for ex. if we would want this file rotated daily you would use: %YYYY%MM%DD
ArchiveLogRecords=%YYYY%MM%DD
- or monthly: %YYYY%MM
ArchiveLogRecords=%YYYY%MM

For example using:
PurgeLogFile=1
ArchiveLogRecords=%YYYY%MM

will create the following monthly archive files:
awstats_archive.configname.200804.log
awstats_archive.configname.200805.log
...

and from here you can compress them, archive them, or even pipe them to another analyzer software if you need that .

Coolsearchinfo - A free Social Bookmarking Site

Liked this article? To continue getting our latest free Howtos and Tutorials,
you can also grab the RSS feed or Subscribe to Techgurulive by Email

Not Getting



Related posts
  • The –prefix=/usr/local/apache Argument
    You use this argument to specify the path where Apache should be installed on the file system. In this case, the path is specified as /usr/local/apache. This is the default...
  • Installing Apache on Linux – RPM Installation
    You can handle RPM installation with a single command. However, you should follow a few guidelines within the context of RPMs. Before you begin downloading the RPM, ensure the following:...