How to include server name in apache log file name?

I want to configure apache so that the access and error logs generated from apache include are named as follows:

<server-name>_access_<timestamp>
<server-name>_error_<timestamp>

I have a timestamp obtained using rotatelogs:

CustomLog logs/access_log combined
CustomLog "|bin/rotatelogs -l /var/logs/access_%Y-%m-%d 86400" common

The part I cannot find is how to include the server name in the file name. I am configuring Apache in a linux box.

Regards, Mohan

+3
source share
2 answers

It seems that like Apache HTTPD 2.4, no function provides this feature.

http://httpd.apache.org/docs/current/mod/mod_log_config.html#customlog

- , , , , script VirtualHost. , .

+1

mod_log_config; iIt , %v, %v:

%...v    The canonical ServerName of the server serving the request.
%...V    The server name according to the UseCanonicalName setting.
0

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


All Articles