Apache HTTP Server Configuration

This package supports the default common and combined format for Apache HTTP Server access logs and a simple error log format. However, It is recommended that you add some custom fields to the default access and error logs to provide a richer set of data to ingest to LogScale.

The following steps detail how to add a custom server_name field to the access log and how to set up the error log format.

The package dashboards assume these custom fields exist and make use of them in many widgets.

If these custom fields are not present, some widgets may not display data or be incomplete. If your logs use a custom format that does not match those used below, see the Extending Parsers for Custom Logs for further options.

Configuring Log Formats

To enable the custom fields please make the changes as described below.

Changes should be made in the Apache configuration file located in /etc/apache2/apache2.conf

Access Log

The first step is to add the server name to either the "combined" or "common" log format (whichever one you might be using).

The server name is referenced with %v:

apache
LogFormat "%h %l %u %t \"%r\" %>s %O\"%{Referer}i\" \"%{User-Agent}i\"" combined // combined format, default
LogFormat "%v %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined // combined format, with server name added
LogFormat "%h %l %u %t \"%r\" %>s %O" common // common format, default
LogFormat "%v %h %l %u %t \"%r\" %>s %O" common // common format, with server name added

Then you can use the CustomLog directive to specify the location of a log file as well as the log format to be used for those logs.

apache
CustomLog "/var/log/apache2/access.log" combined

Error Log

For the error log, the parser in the package expects this format:

apache
ErrorLogFormat "%v [%t] [%m:%l] [pid %P:tid %T] [client\ %a] %M"

This picks up the ErrorLog

apache
ErrorLog "/var/log/apache2/error.log"

More detailed information about the configuration can be found in the Apache documentation.