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.

SOLVED Global Log

Discussion in 'EasyApache' started by grayloon, Jan 11, 2017.

  1. grayloon

    grayloon Well-Known Member

    Joined:
    Oct 31, 2007
    Messages:
    102
    Likes Received:
    2
    Trophy Points:
    68
    Location:
    Evansville, IN
    cPanel Access Level:
    Root Administrator
    Twitter:
    I just switched from EA3/Apache 2.2 to EA4/Apache 2.4. Previously, I had a the following in my
    /usr/local/apache/conf/includes/pre_main_global.conf file:
    Code:
    <IfModule mod_log_config.c>
        LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" mycustom
    </IfModule>
    Then, I had the following in /usr/local/apache/conf/userdata/global-access_log.conf:
    Code:
    CustomLog /var/log/httpd/global-apache-access_log mycustom
    That was working great for several years. Now, I'm trying to set up the same thing with EA4, and I can't get it to log to the global log file. I added both of those directives to /etc/apache2/conf.d/includes/pre_main_2.conf, I added them to the bottom of my httpd.conf file, but nothing is working. I searched the forums and found all types of answers spanning several years. Is there currently a definitive way to do this?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @grayloon,

    You should be able to complete the following steps to customize the LogFormat entry:

    1. Copy the Apache 2.4 template for EasyApache 4 to allow for customization:

    Code:
    cp -a /var/cpanel/templates/apache2_4/ea4_main.default /var/cpanel/templates/apache2_4/ea4_main.local
    2. Edit /var/cpanel/templates/apache2_4/ea4_main.local to change the entries to match your preferences:

    Code:
    vi /var/cpanel/templates/apache2_4/ea4_main.local
    Note: You can make custom changes/additions for "CustomLog" in this same file instead of creating an additional configuration file.

    3. Save the changes, and then run:

    Code:
    /scripts/rebuildhttpdconf
    Let us know if this helps.

    Thank you.
     
  3. grayloon

    grayloon Well-Known Member

    Joined:
    Oct 31, 2007
    Messages:
    102
    Likes Received:
    2
    Trophy Points:
    68
    Location:
    Evansville, IN
    cPanel Access Level:
    Root Administrator
    Twitter:
    I added my custom directives to the ea4_main.local file and rebuilt httpd.conf. My custom directives are in the httpd.conf file, but I'm still not seeing any output in my global log file. Here's the relevant section of httpd.conf:
    Code:
    <IfModule log_config_module>
        LogFormat "%{Referer}i -> %U" referer
        LogFormat "%{User-agent}i" agent
        # NOTE: "combined" and "common" are required by WHM
        LogFormat "%h %l %u %t \"%r\" %>s %b" common
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
        LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" mycustom
        CustomLog /var/log/httpd/global-apache-access_log mycustom
    
        # access_log format can be set in WHM under 'Basic cPanel & WHM Setup'
        CustomLog logs/access_log combined
    </IfModule>
     
  4. grayloon

    grayloon Well-Known Member

    Joined:
    Oct 31, 2007
    Messages:
    102
    Likes Received:
    2
    Trophy Points:
    68
    Location:
    Evansville, IN
    cPanel Access Level:
    Root Administrator
    Twitter:
    I just noticed that the global log populates if I access the server via the IP: http://123.456.78.90/. It doesn't populate when I access a vhost though.
     
  5. grayloon

    grayloon Well-Known Member

    Joined:
    Oct 31, 2007
    Messages:
    102
    Likes Received:
    2
    Trophy Points:
    68
    Location:
    Evansville, IN
    cPanel Access Level:
    Root Administrator
    Twitter:
    I figured it out. I had to copy and edit the vhost.default template as well.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    I'm happy to see you were able to address the issue. Thank you for updating us with the outcome.

    Thank you.
     
  7. morrow95

    morrow95 Well-Known Member

    Joined:
    Oct 8, 2006
    Messages:
    104
    Likes Received:
    2
    Trophy Points:
    168
    If using this method will the changes 'stay'? The first thing that shows in this file is :

    ----
    # Direct modifications to the Apache configuration file WILL be lost upon subsequent
    # regeneration of this configuration file, or an Apache update.
    #
    # To have your modifications retained, you should create/edit administrator-specific
    # include files:
    #
    # [% paths.dir_conf_includes %]/pre_main_global.conf
    # [% paths.dir_conf_includes %]/pre_virtualhost_global.conf
    # [% paths.dir_conf_includes %]/post_virtualhost_global.conf

    ----

    I'm just trying to understand how this .local copy with a few changes to the file here and there fits into everything. It reads the default first then the local and overwrites anything that is different? What happens when a change is made to the default and our local 'copy' doesn't have those new changes... in that situation you'd be overwriting any new changes right because your copy is 'old' just with your custom modifications.
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    The ".local" template takes precedence over the ".default" template. You'd have to manually update the ".local" template every time a new default template is issued. As of cPanel 64.0.19, notifications are sent when the EA4 default templates are updated and a local template file exists:

    Fixed case CPANEL-12933: Notify admins of EA4 template changes if .local versions exist.

    Thank you.
     
Loading...

Share This Page