Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Global Log

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

  1. grayloon

    grayloon Well-Known Member

    Joined:
    Oct 31, 2007
    Messages:
    108
    Likes Received:
    3
    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 Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. grayloon

    grayloon Well-Known Member

    Joined:
    Oct 31, 2007
    Messages:
    108
    Likes Received:
    3
    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:
    108
    Likes Received:
    3
    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:
    108
    Likes Received:
    3
    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 Technical Support Community Manager
    Staff Member

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

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. morrow95

    morrow95 Well-Known Member

    Joined:
    Oct 8, 2006
    Messages:
    123
    Likes Received:
    3
    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 Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. grayloon

    grayloon Well-Known Member

    Joined:
    Oct 31, 2007
    Messages:
    108
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Evansville, IN
    cPanel Access Level:
    Root Administrator
    Twitter:
    I'm diving back into this, because a cPanel support tech slapped my hand for having a really outdated .local file in place. I removed the file to get my server working properly, but I'd still like to use some type of global Apache logging. I turned on the piped logging feature, but I didn't see where it was creating any type of combined log for all virtual hosts. Any further suggestions?
     
  10. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,898
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @grayloon,

    The easier approach would be to use a bash command that shows you the output of multiple or all domain access logs as opposed to changing the way Apache logs the data. You'd use less system resources this way. Is the purpose of this customization to allow you to view all of the Apache domain access logs in a single location, or is it due to some other need?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice