Skip to main content

Master Log File in WHM

Comments

7 comments

  • cPanelMichael
    Hello, There's no native feature in cPanel/WHM to facilitate a combined Apache access log, however a user submitted a custom workaround on the following thread: apache master/custom/global access log Could you review this thread and let us know if this solution is suitable for what you need? Thank you.
    0
  • WorkinOnIt
    Thank you - that is indeed very helpful and I am not sure why I was unable to come across that thread during searches! I am also (like the other poster) surprised this is not a native feature! I am a bit of a novice and have some questions that I wonder you can assist with? In the thread mentioned here the OP SergeiF suggests the following: The correct place to put the log line is in /var/cpanel/templates/apache2/vhost.local (cp from vhost.default):
    However, in my cpanel/templates directory - I have the following folders: apache2 apache2_0 apache2_2 apache2_4 Each of these contain the same files: - main.default - ssl_vhost.default - vhost.default I am running 2.4 so which folder should I place the log lines in? I also don't seem to have the vhost.local file mentioned - what does cp from vhost.default mean? Another question: I presume this will not interfere with the individual log files that are being generated? I still want clients to be able to access e.g. awstats in cpanel. Also, once created - where would I set up the log rotate for this file? Should that be done in logrotate.conf - or should I do this through WHM > Service Configuration > cPanel Log Rotation Configuration Thanks
    0
  • cPanelMichael
    I am running 2.4 so which folder should I place the log lines in? I also don't seem to have the vhost.local file mentioned - what does cp from vhost.default mean?

    I suggest using "/etc/apache2/logs/" as the log storage directory if you are using EasyApache 4. Otherwise, you can use "/usr/local/apache/logs" on EasyApache 3. You should utilize the "/var/cpanel/templates/apache2_4" directory if you are using Apache 2.4. Additional information about these template files is available: Custom Templates - EasyApache - cPanel Documentation The "cp from vhost.default" reference on that thread is an instruction to copy the "vhost.default" file with a Linux command such as "cp -a /var/cpanel/templates/apache2_4/vhost.default /var/cpanel/templates/apache2_4/vhost.local".
    Another question: I presume this will not interfere with the individual log files that are being generated? I still want clients to be able to access e.g. awstats in cpanel.

    The custom workaround doesn't reference the individual domain access logs. You could always use a custom entry that relies on that workaround and the existing entry of:
    [% IF logstyle == 'combined' -%] [%- IF !enable_piped_logs || !supported.mod_log_config -%] CustomLog [% paths.dir_domlogs %]/[% wildcard_safe(vhost.log_servername) %] combined
    Also, once created - where would I set up the log rotate for this file? Should that be done in logrotate.conf - or should I do this through WHM > Service Configuration > cPanel Log Rotation Configuration

    You could configure your system's LogRotate utility to rotate this custom log file by creating a new configuration file in the "/etc/logrotate.d/" directory. Instructions on using LogRotate are available at: logrotate Thank you.
    0
  • WorkinOnIt
    Thank you for your assistance. A few more questions; 1) I presume once I've added this entry to vhost.local I should restart Apache? Or? 2) I am using log_config_module - is this the correct syntax for adding the entry using the following?
    LogFormat "%V %a %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" vcommon CustomLog /var/log/httpd/vhost-access_log vcommon
    3) Also does it matter where the log file is placed? At the moment the OP suggested /var/log/httpd/vhost-access_log vcommon - I don't have an httpd folder in that location - could I add the log file to /usr/local/apache/logs/ ? Thanks
    0
  • WorkinOnIt
    Further to my above, I've copied the file /var/cpanel/templates/apache2_4/vhost.default and added the log lines to vhost.local and restarted Apache but I am not seeing any log files generated. Do I need to restart the server? Here's what I have done: 1) copied vhost.defaul to vhost.local and at the footer, right after this:
    [%- IF !added_include %] [%- IF apache_target_version %] [%- SET vhost_include_base = paths.dir_conf_userdata _ "/std/$apache_target_version/" %] [%- ELSE %] [%- SET vhost_include_base = paths.dir_conf_userdata _ '/std/2_4/' %] [%- END %] [%- domain = legacy_wildcard_safe(vhost.servername) %] # To customize this VirtualHost use an include file at the following location # Include "[% vhost_include_base %][% vhost.user %]/[% domain %]/*.conf" [%- END %]
    I have added this:
    LogFormat "%V %a %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" vcommon CustomLog /usr/local/apache/logs/vhost-access_log vcommon
    I'm assuming the location of the log is not critical? The OP suggested /var/log/httpd/vhost-access_log vcommon - I don't have an httpd folder in that location. My httpd.conf file is located here: /usr/local/apache/conf/ Should the log entry show in the virtual hosts httpd file? Thanks
    0
  • WorkinOnIt
    @cPanelMichael Would the log work if I add directly to httpd virtual host block? Not having any luck with the above Thanks
    0
  • cPanelMichael
    Would the log work if I add directly to httpd virtual host block? Not having any luck with the above

    Could you verify the specific steps you would use with this method? Thank you.
    0

Please sign in to leave a comment.