The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to customize LogFormat for Apache Virtual Hosts?

Discussion in 'General Discussion' started by M373H, Apr 24, 2015.

  1. M373H

    M373H Member

    Joined:
    Jan 18, 2015
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I really need some help with this. My server has multiple virtual hosts, each virtual host has its access log, I need to be able to customize the LogFormat for each virtual host exist on server. I have modified LogFormat in httpd.conf but it actually affects only the master access log and not the virtual hosts.

    Here is my LogFormat:
    Code:
    <IfModule log_config_module>
    LogFormat "%v:%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{CF-Connecting-IP}i" combinedvhost
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{CF-Connecting-IP}i" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b %{CF-Connecting-IP}i" common
     
    CustomLog "logs/access_log" combined
    CustomLog logs/access_log combinedvhost
     
    <IfModule logio_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{CF-Connecting-IP}i" combinedio
    </IfModule>
     
    </IfModule>
     
    <IfModule mod_log_config.c>
    LogFormat "%v:%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{CF-Connecting-IP}i" combinedvhost
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{CF-Connecting-IP}i" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b %{CF-Connecting-IP}i" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent
     
    CustomLog logs/access_log common
    CustomLog logs/access_log combined
    CustomLog logs/access_log combinedvhost
     
    </IfModule>
    The above LogFormat only affects the master access log which located at: /usr/local/apache/logs/access_log However, it does not affect any of the virtual hosts on server that have their access logs located at: /home/username/access-logs/domain.com

    I'm not sure if I have something wrong in the LogFormat itself or I'm missing something. I've spent many hours trying to solve this problem but didn't find a solution. I'd greatly appreciate it if someone could shed some light on this. Thank you.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    You should not have to create a LogFormat entry for each virtual host. You can simply modify the main LogFormat entries, which should apply to the Apache domlogs. The following document should help:

    Advanced Apache Configuration

    Thank you.
     
  3. M373H

    M373H Member

    Joined:
    Jan 18, 2015
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thank you for your reply :)

    I reversed back all httpd.conf changes, then switched from Nginx Admin to cpnginx and everything worked fine.

    Sorry for the inconvenience.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator

Share This Page