Mobile app version of vmapp.org
Login or Join
Dunderdale272

: Include number and date in Apache log file names I'm trying to figure out how to include the current date and the IP number of the current host inside the Apache log file names, but I fail

@Dunderdale272

Posted in: #Apache #ApacheLogFiles #Filenames

I'm trying to figure out how to include the current date and the IP number of the current host inside the Apache log file names, but I fail how to see how I can do that. Part of that has to do with the fact that I don't understand the log rotation mechanism that seems to be enabled by default. Haven't been able to find any documentation on why I have access.1.log, access.xxx.gz.log files.

(I mean, I do understand that it is log rotation, but I don't see how I can influence it. I also understand I could pipe log output through some sort of command to include the current IP number in the file name, but I would assume I would lose my log rotation that way. Basically I want the current mechanism, but then include the IP number in the name, and a date rather than a number.)

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Dunderdale272

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

This is how log rotation is handled on my Apache server.

LogFormat "%h %l %u %t "%r" %>s %b" common
CustomLog "|/usr/local/sbin/cronolog --american /usr/local/apache2/logs/access_log.%Y%m%d" common


Cronolog creates a daily log file named something like access_log.20120213. I then have a cron job set to move old logs into a subdirectory, gzip logs files older than a week and clean out anything older than one year.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme