Apache Log Files

Q. How do I find out Apache http server log files location? How do I change the location of Apache log file under Linux / UNIX operating system?

A. There are two type of apache httpd server log files:

ADVERTISEMENTS

Apache Error Log File

All apache errors / diagnostic information other errors found during serving requests are logged to this file. Location of error log is set using ErrorLog directive. If there is any problem, you should first take a look at this file using cat, grep or any other UNIX / Linux text utilities. This apache log file often contain details of what went wrong and how to fix it. Default error log file location:

  • RHEL / Red Hat / CentOS / Fedora Linux Apache error file location – /var/log/httpd/error_log
  • Debian / Ubuntu Linux Apache error log file location – /var/log/apache2/error.log
  • FreeBSD Apache error log file location – /var/log/httpd-error.log

To find exact apache log file location, you can use grep command:
# grep ErrorLog /usr/local/etc/apache22/httpd.conf
# grep ErrorLog /etc/apache2/apache2.conf
# grep ErrorLog /etc/httpd/conf/httpd.conf

Sample output:

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a 
ErrorLog "/var/log/httpd-error.log"

Apache Access Log File

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

How do I change Apache log file location?

Simply edit apache configuration file and change the location. You need define new location using CustomLog or ErrorLog:

ErrorLog "/home/httpd/cyberciti.biz/rawlogs/httpd-error.log"
CustomLog "/home/httpd/cyberciti.biz/rawlogs/httpd-access.log" combined

Save and close the file. Restart httpd:
# service httpd restart

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
23 comments… add one
  • r00tUser Jun 14, 2008 @ 14:34

    You can also use the following command to find the log files if the apache instance is running.

    lsof -p |grep -i logs

    This would give the access and the error logs.

    Cheers,
    rOOtUser

    • john kamenos Oct 26, 2011 @ 15:21

      thanks

  • r00tUser Jun 14, 2008 @ 14:35

    Disregard the previous command.

    lsof -p pid-of-httpd | grep -i logs

    • Uncle Weasel Jan 6, 2011 @ 18:15

      Good one r00tUser that is a neat one-liner.

  • AHmed Dec 15, 2008 @ 22:44

    Thank you too much

  • Arif Aug 26, 2009 @ 9:13

    how to learn the number of requests for a file in apache logs?

    thanks.

  • THOTA SIVA PRASAD Oct 22, 2009 @ 12:34

    i want log file formats for server log,access log,user log,browser log,proxy log ,error log ect.

  • robert Aug 9, 2010 @ 11:29

    How can I move my /var/log directory to RAM (tmpfs) and not have Apache fail to load because it can’t find “error.log” when I reboot?

  • Techie Sep 6, 2010 @ 18:44

    Thanks. I didn’t know where the logs were and I just wanted to manually look through the access log.

  • Tasman Hayes Mar 8, 2011 @ 13:30

    Thanks for covering the the Apache log file locations for Red Hat, CentOS and Ubuntu. Very useful!

  • Joe Johnson Jun 27, 2011 @ 1:35

    Excellent guide; thank you very much!

  • Rakshtiha Megha Jul 18, 2011 @ 9:54

    Hi,
    wat are the different command to retrive the contents of Server LOG file and fhow do it accecc the contens of Serevr LOG file.

  • ebi Jul 22, 2011 @ 12:20

    Forbidden

    You don’t have permission to access / on this server.

    Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

  • Shruthi Nov 23, 2011 @ 12:55

    Hi,

    Please help me out with this Apache Log file settings that i want to achieve:
    1. The Log file size should be restricted to 100 MB
    2. Once the log file reaches 100 MB, it should create a new log file
    3. Maximum we should be backing up 10 log files.

    I need this on urgent basis, please help

  • TonyRiver Dec 29, 2011 @ 10:25

    Is this the same in CentOS, Fedora, and Redhat?

  • tony b Jan 26, 2012 @ 6:10

    What would a file called _PO.log be?

  • Haris Ibrahim K. V. Feb 25, 2012 @ 15:22

    Thanks mate. I was checking out where to find the error log files of apache and this one solved it for me.

  • Marek Mar 30, 2012 @ 20:05

    Have you ever had this error after changing access_log file destination folder?

    [error] (13)Permission denied: could not open transfer log file /tmp/apache2/access.log
    I’ve set chmod of apache2 to 777 and owner to apache, working on new installation of Centos 6.2

  • phusitw Apr 8, 2012 @ 17:00

    good krub

  • asaad Apr 19, 2012 @ 9:05

    Hello everyone,
    please i want to know how i can find and download a search log file ( For example for a Google or Yahoo ) , because i need the log file to study and analysis the queries that made by the user of these search engines.

    Best regard
    Asaad

  • vinod Apr 30, 2013 @ 11:20

    Hi,

    Please help me out with this maillog Log file settings that i want to achieve:
    1. The Log file size should be restricted to 20 GB
    2. Once the log file reaches 4GB, it should create a new log file
    3. Maximum we should be backing up 10 log files.

    I need this on urgent basis, please help

  • Amardip May 15, 2014 @ 6:58

    These all above commands are for linux..But where can i find apache log files on windows?

  • Jose Tapia Apr 30, 2015 @ 16:48

    Great stuff thanks for the info, very usefull

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.