Delicious Bookmark this on Delicious

Computer Forums

Apache server configuration on Linux - Apache logs


There are essentially two types of logs for Apache: access logs and error logs. Both types of logs are controlled by different directives:
  • Access logs: they are controlled via the module log_config (can be compiled with Apache or added as a shared library). You can use the LogFormat directive in order to precise the format of your log and the CustomLog directive in order to effectively create the access log at the required server locaton:

    < IfModule log_config_module >
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    CustomLog "logs/access_log" common
    < /IfModule >

    Note that the lines above come from the default httpd.conf configuration file after Apache has just been installed. The IfModule condition is here to insure that the directives are set only if the log_config module is active (compiled or as shared dynamic object). If you know log_config is active on your server, the conditional tag becomes of course irrelevant.
  • Error logs: they are controlled via the Apache core module. In order to choose the format of the log, you can use the directive LogLevel which will indicate the level of details you can expect from your log. Available levels (by decreasing level of details) are: debug, info, notice, warn, error, crit, alert, emerg. Therefore, the following directive shall yield the most detailed kind of error logging:

    LogLevel debug

    In order to actually create the error log, you must use the directive ErrorLog:

    ErrorLog "logs/error_log"

In this tutorial we have seen how to configure an Apache server on Linux by editing the Apache configuration file httpd.conf. The next step towards a proper Apache installation is to understand how to harden an Apache server - how to improve an Apache server security.

Computer Forums

Next tutorial: Installing PHP on an Apache server


Back to computer forums