Apache Log Files

Posted on in Categories , , , , , , , , , , , last updated June 8, 2008

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:

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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

Share this on (or read 23 comments/add one below):

23 comment

  1. 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

  2. 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.

  3. 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

  4. 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

  5. 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

  6. 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

Leave a Comment