How to modify Apache log format for the domains hosted on Plesk

November 10, 2023 / Plesk

This guide explains how to modify Apache log format for the domains hosted on Plesk. Apache logs are files generated by the Apache HTTP Server that contain information about server activity, including details about incoming requests, errors, and other relevant events.

To adjust the Apache log format for domains hosted on Plesk, follow these steps-

  1. Access the SSH terminal.
  2. Generate custom template folder- /usr/local/psa/admin/conf/templates/custom/ by using-
    mkdir -p /usr/local/psa/admin/conf/templates/custom/
  3. Duplicate /usr/local/psa/admin/conf/templates/default/server.php into custom template folder by executing-
    cp -a /usr/local/psa/admin/conf/templates/default/server.php
    /usr/local/psa/admin/conf/templates/custom/server.php
  4. Now, open file- /usr/local/psa/admin/conf/templates/custom/server.php using any text editor.
  5. Modify log format in custom template 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>
  6. Now, check whether the modified template is a justifiable PHP file, using the following-
    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. Rebuild the server configuration using the new template-
    plesk sbin httpdmng –reconfigure-server

Caution- Modifying the Apache access log format can potentially disrupt web statistics calculations since webstat tools like Webalizer and Awstats rely on the Common Log Format (CLF), which adheres to strict syntax rules for each line in the log file.

 

In such manner, you can modify Apache log format for the domains hosted on Plesk. If you encounter any challenges, please reach out to our support team for assistance.

Dominos Search