Setting apache error log file name to include current date

I try to have apache create a new error log file every day based on the current date. The default error log file name looks something like this: ErrorLog "/logs/error.log"

and I want it to be something like: ErrorLog "/logs/error_$year$month$day.log"

Any ideas?

+3
source share
3 answers

Take a look at Cronolog

cronolog - , . , . -, Apache, .

+1

, logrotate apache apache , ..

, :

%...{format}t:  The time, in the form given by format, which should
                be in strftime(3) format. (potentially localized)

strftime (man 3 strftime):

%F or its equivalent without dashes %Y%m%d

:

# CustomLog with explicit format string
CustomLog my_log "%{%Y%m%d}t %h %l %u %t \"%r\" %>s %b"

% {% Y% m% d} t

0

httpd.conf

ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"

, 5 , errorlog.YYYY-mm-dd-HH_MM_SS.

0
source

Source: https://habr.com/ru/post/1712761/


All Articles