Article ID: 127357, created on Nov 7, 2015, last review on Nov 7, 2015

  • Applies to:
  • Plesk Automation 11.5


How modify LogFormat for the Apache logs on Linux web-hosting service nodes in Plesk Automation?


Plesk Automation defines global log format that will be used for all virtual hosts and assigns nickname 'plesklog' to this log format:

LogFormat "%v@@%p@@%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" plesklog

In order to modify this directive for all virtual hosts on the Service Node you need to do the following:

  1. Login to PA Management node and copy default web server configuration file. Based on it, PA applies changes on Apache nodes:

    # mkdir /usr/local/psa/admin/conf/templates/custom/
    # cp -rp /usr/local/psa/admin/conf/templates/default/server.php /usr/local/psa/admin/conf/templates/custom/

    Important: Do not change the default templates. To introduce your changes to the configuration, copy the templates you need to the /usr/local/psa/admin/conf/templates/custom/ directory and modify them, preserving the directory structure, and then modify these copies. You can create templates from scratch and place them in the custom/ directory according to the default structure.

  2. Add necessary directives in /usr/local/psa/admin/conf/templates/custom/server.php. For example if you need to track %{X-Forwarded-For}i add this value in <IfModule mod_logio.c> and <IfModule !mod_logio.c> sections:

    # cat /usr/local/psa/admin/conf/templates/custom/server.php
        <IfModule mod_logio.c>
            LogFormat "<?php echo $VAR->server->webserver->apache->pipelogEnabled ? '%v@@%p@@' : ''?>%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-Forwarded-For}i\"" plesklog
        <IfModule !mod_logio.c>
            LogFormat "<?php echo $VAR->server->webserver->apache->pipelogEnabled ? '%v@@%p@@' : ''?>%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-Forwarded-For}i\"" plesklog

    Important:: Don't forget that special symbols like " should be escaped with \.

  3. Check that the modified templates are valid PHP files:

    # 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
  4. Generate new configuration files, replace with your Linux web hosting service node:

    # /usr/local/psa/admin/bin/httpdmng --reconfigure-server -service-node

Search Words

Change LogFormat

Changing Virtual Hosts Settings Using Configuration Templates

Virtual Host Configuration Template

Apache log format


33a70544d00d562bbc5b17762c4ed2b3 caea8340e2d186a540518d08602aa065 e0aff7830fa22f92062ee4db78133079

Email subscription for changes to this article
Save as PDF