Articles in this section

How to change Apache log format for the domains hosted on Plesk?

kb: how-to Plesk for Linux

Applicable to:

  • Plesk for Linux

Question

How to change Apache log format for the domains hosted on Plesk?

Answer

  1. Log in to the server via SSH

  2. Create /usr/local/psa/admin/conf/templates/custom/ custom template folder:

    # mkdir -p /usr/local/psa/admin/conf/templates/custom/

  3. 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

  4. Open /usr/local/psa/admin/conf/templates/custom/server.php file using any text editor.

  5. Change log format in custom template in the following section according to Apache documentation:

    CONFIG_TEXT: <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>

  6. 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

  7. 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

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.