207

Does anyone know where file access logs are stored, so I can run a tail -f command in order to see who is accessing a particular file.

I have XAMPP, which is an Apache server installed on my machine, which automatically logs the accesses. It is stored in my installation folder.

1
  • On what distribution, or with what hosting provider? Logs are typically under /var/log, but some systems have them elsewhere. May 19, 2012 at 12:51

4 Answers 4

233

Ultimately, this depends on your Apache configuration. Look for CustomLog directives in your Apache configuration, see the manual for examples.

A typical location for all log files is /var/log and subdirectories. Try /var/log/apache/access.log or /var/log/apache2/access.log or /var/log/httpd/access.log. If the logs aren't there, try running locate access.log access_log.

0
46

If you can't find the log with Gilles's answer, there are a couple more things you can try.

  • Look in /var/log/httpd.
  • Run sudo locate access.log as well as sudo locate access_log. The logs on my system were not visible except to root, and the file was called access_log instead of access.log.
0
33

Apache server records all incoming requests and all requests processed to a log file. The format of the access log is highly configurable. The location and content of the access log are controlled by the CustomLog directive. Default apache access log file location:

RHEL / Red Hat / CentOS / Fedora Linux Apache access file location –

/var/log/httpd/access_log

Debian / Ubuntu Linux Apache access log file location –

/var/log/apache2/access.log

FreeBSD Apache access log file location –

 /var/log/httpd-access.log

To find exact apache log file location, you can use grep command:

# grep CustomLog /usr/local/etc/apache22/httpd.conf
# grep CustomLog /etc/apache2/apache2.conf
# grep CustomLog /etc/httpd/conf/httpd.conf

Sample output:

# a CustomLog directive (see below).
#CustomLog "/var/log/httpd-access.log" common
CustomLog "/var/log/httpd-access.log" combined 
3
  • 4
    The best answer in my opinion: detailed, concise and multi-platform for most *nix. Jun 17, 2016 at 23:15
  • This whole answer was copied from this page: cyberciti.biz/faq/apache-logs Nov 7, 2018 at 0:51
  • Just remember to search also in defined virtual servers, i.e., on Ubuntu, their individual config files are in /etc/apache2/sites-enabled/.
    – Fjor
    Oct 25, 2022 at 4:02
9

find Apache access.log file location on Debian / Ubuntu Linux

On my machine /etc/apache2/apache2.conf pointed to ${APACHE_LOG_DIR} environment variable instead of the log directory itself.

The following (additional) step has been required to find the actual log directory:

$ grep APACHE_LOG_DIR /etc/apache2/envvars
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
$

envvars contains default environment variables for Apache.

Thus, to view the access log, use

$ sudo tail -f /var/log/apache2/access.log

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .