Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to find where Apache is keeping the access and error logs for a site.

I have root access to a server where dozens of sites are hosted. I'm trying to debug one of those sites. When I browse the site, it doesn't show up on /var/logs/apache2/access.log or /var/logs/apache2/error.log. (The files are there, and other sites gets logged on those. In fact, there are hundreds of different log files).

Neither locate httpd.log nor find . -iname httpd.log performed at / issue any results.

The apache configuration for the site is:

ServerName REDACTED.com.br
DocumentRoot /var/www/xyz/wiki
AssignUserId xyz_wiki xyz_wiki

<Directory /var/www/xyz/wiki/data>
order allow,deny
deny from all
</Directory>
<Directory /var/www/xyz/wiki/conf>
order allow,deny
deny from all
</Directory>
<Directory /var/www/xyz/wiki/bin>
order allow,deny
deny from all
</Directory>
<Directory /var/www/xyz/wiki/inc>
order allow,deny
deny from all
</Directory>

php_admin_value open_basedir /var/www/xyz/wiki/:/mnt/vdImagem/www/xyz/wiki/
share|improve this question
3  
This is not a dupe, the OP has linked to the proposed duplicate in the question itself and clearly states that the info is not in /var/log/apache2/access.log which is what the duplicate suggests. –  terdon Feb 19 at 19:38
    
Try sudo lsof -nP -c apache2 -c httpd | grep -i log –  Stéphane Chazelas Feb 19 at 21:58

3 Answers 3

Look in your apache config for the string ErrorLog.

Usually there's one for the Apache process itself. Each VirtualHost can also define its own log files so check those as well.

If the VirtualHost doesn't define its own log file then it will be using the one specified in the global configuration. If you think you've found the correct log file but you aren't seeing the information you need then try increasing the LogLevel.

share|improve this answer
    
/etc/apache2# rgrep "ErrorLog" . displays dozens of config files that specify ${APACHE_LOG_DIR}/error.sitename.log, but this is not one of those. /etc/apache2# rgrep "LogLevel" . gets me only a few default files. –  That Brazilian Guy Feb 19 at 20:13
    
On Debian ${APACHE_LOG_DIR} is defined as /var/log/apache2 by default. Check /etc/defaults/apache2 to see if it has been changed. –  bahamat Feb 19 at 22:34
    
If there's no LogLevel set for a particular VirtualHost you can add one. –  bahamat Feb 19 at 22:35

I just found a file /etc/apache2/conf.d/other-vhosts-access-log which contains

# Define an access log for VirtualHosts that don't define their own logfile
CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined

Looks like it is a way to combine all logs from vhosts in a single file. I have checked and the accesses were being recorded there.

(source)

Inserting an ErrorLog and an AccessLog directive on the config file for that site provided me separate log files.

share|improve this answer

You can inquire about his information from Apache's log files but it's generally better to inquire about these things from the actual executable. Parsing the logs can be tricky and you'll likely make a mistake if you aren't that familiar with how a particular setup was done on a box.

httpd -V

$ httpd -V
Server version: Apache/2.2.15 (Unix)
Server built:   Feb 13 2012 22:31:42
Server's Module Magic Number: 20051115:24
Server loaded:  APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

The key items you want to look at are as follows.

  1. This tells you the "root" directory that all the files Apache will reference start from:

     -D HTTPD_ROOT="/etc/httpd"
    
  2. config files are defined, starting here. Note that this path is relative to the path mentioned in #1, so it would be /etc/httpd/conf/httpd.conf.

     -D SERVER_CONFIG_FILE="conf/httpd.conf"
    
  3. Error log is here.

     -D DEFAULT_ERRORLOG="logs/error_log"
    

    NOTE: This one might be a bit confusing at first but on Red Hat distros there is a link that is often made in this directory, /etc/httpd called logs.

    $ ls -ld /etc/httpd/logs
    lrwxrwxrwx. 1 root root 19 Jul  9  2012 /etc/httpd/logs -> ../../var/log/httpd
    
  4. Other log files that might be utilized by Apache will be defined further in the config file, /etc/httpd/conf/httpd.conf.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.