Question
How to change Apache log format for the domains hosted on Plesk?
Answer
-
Log in to the server via SSH
-
Create
/usr/local/psa/admin/conf/templates/custom/
custom template folder:# mkdir -p /usr/local/psa/admin/conf/templates/custom/
-
Copy
/usr/local/psa/admin/conf/templates/default/server.php
into custom template folder:# cp -a /usr/local/psa/admin/conf/templates/default/server.php /usr/local/psa/admin/conf/templates/custom/server.php
-
Open
/usr/local/psa/admin/conf/templates/custom/server.php
file using any text editor. -
Change log format in custom template in the following section according to Apache documentation:
<IfModule mod_logio.c>
LogFormat "<?php echo $VAR->server->webserver->apache->pipelogEnabled ? '%v@@%p@@' : ''?>%a %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" plesklog
</IfModule>
<IfModule !mod_logio.c>
LogFormat "<?php echo $VAR->server->webserver->apache->pipelogEnabled ? '%v@@%p@@' : ''?>%a %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" plesklog
</IfModule> -
Check that the modified template is a valid PHP file:
# php -l /usr/local/psa/admin/conf/templates/custom/server.php
No syntax errors detected in /usr/local/psa/admin/conf/templates/custom/server.php -
Regenerate server configuration based on the new template:
# plesk sbin httpdmng --reconfigure-server
Warning: Customizing Apache access log format may break webstatistics calculation as webstat tools (Webalizer and Awstats) use Common Log Format (CLF) where each line in a file stored in the Common Log Format has the strictly defined syntax.
Additional Information
Changing Virtual Hosts Settings Using Configuration Templates on Plesk
Apache Official Documentation: Log Files