View the error log for the Apache server on the Linux system

  • 2020-05-14 05:27:34
  • OfStack

The error log and access log files provide system administrators with useful information, such as blocking the Web server, protecting the system from all kinds of malicious activity, or simply performing all kinds of analysis to monitor the HTTP server. Depending on your Web server configuration, the error/access logs may be located in different locations on your system.

This article will help you find the Apache error log on Linux.
The Apache error log location on Debian, Ubuntu, or Linux Mint
Default error logging

On based on Debian Linux, system-wide Apache error log is the default location/var log/apache2 / error log. The default location can be changed by editing the Apache configuration file.
Custom error logs

To find the position of the custom error log, please use a text editor open/etc/apache2 / apache2 conf, then find begin with ErrorLog line, it specifies the custom Apache the location of the error log file. For example, the following lines can be found in the unmodified Apache configuration file:


  ErrorLog ${APACHE_LOG_DIR}/error.log

In this case, the location is configured using the APACHELOGDIR environment variable, which is already defined in /etc/apache2/envvars.


  export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

In practice, ErrorLog might point to any path in your Linux system.
Use a virtual host custom error log

If a virtual host is used in an Apache Web server, the ErrorLog directive may be specified in the virtual host container, in which case the system-wide error log location described above will be ignored.

With the virtual host enabled, each virtual host can define its own custom error log location. To find the error log location for a particular web host, you can open /etc/apache2/ sites-enabled /.conf and look for the ErrorLog directive, which displays the error log file specified by the site.
Apache error log location on CentOS, Fedora or RHEL
Default error logging

Based on Red Hat Linux, system-wide Apache error log file by default is placed in/var log/httpd/error_log. This default location can be customized by modifying the Apache configuration file.
Custom error logs

To find out the custom Apache error log, please use a text editor open/etc httpd/conf/httpd conf, then find ServerRoot, this parameter shows the Apache Web server at the top of a directory tree, log files and configuration are located in the directory tree. Such as:


  ServerRoot "/etc/httpd"

Now, look for the line beginning with ErrorLog, which indicates where the Apache Web server wrote the error log. Note that the specified position is the relative position of the ServerRoot value. Such as:


  ErrorLog "log/error_log"

Combining the above two instructions, can obtain the complete error log path, by default, the path is/etc httpd/logs/errorlog. In a fresh install Apache, this is 1 to/var/log/httpd/errorlog symbolic links.

In practice, ErrorLog may point to any location in your Linux system.
Use a virtual host custom error log

If you enable the virtual host, you can check/etc/httpd/conf/httpd conf (or any other file defines the virtual host) to find the error log position of each virtual host. Look for ErrorLog in the standalone web host section. Such as the virtual host part below, the location of the error log is/var www/xmodulo com/logs/error_log.


  <VirtualHost *:80>
    ServerAdmin webmaster@xmodulo.com
    DocumentRoot /var/www/xmodulo.com/public_html
    ServerName www.xmodulo.com
    ServerAlias xmodulo.com
    ErrorLog /var/www/xmodulo.com/logs/error_log
    CustomLog /var/www/xmodulo.com/logs/access_log
  <VirtualHost>


Related articles: