Collecting Apache Logs
  • 06 Feb 2020
  • 1 Minute To Read
  • Contributors
  • Print
  • Share
  • Dark
    Light

Collecting Apache Logs

  • Print
  • Share
  • Dark
    Light

To enable Retrace to monitor your Apache web application access logs:

Enable Log Collection

In Retrace Server Settings, enable the Apache Access Logs option found under Log Collectors.

Configure LogFormat

Adjust your Apache configuration to include the following:

Add stackify LogFormat.

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %D" stackify

Note: If you are using multiple LogFormats, be sure to put the stackify LogFormat at the top of the order.

Update your application's CustomLog to reference the stackify LogFormat.

<VirtualHost *:80>
    DocumentRoot /var/www/www.foo.com/htdocs
    ServerName www.foo.com
    CustomLog /var/log/apache/access_myvhost.log stackify
    ErrorLog /var/log/apache/www.foo.com-error.log
</VirtualHost>

Check Permissions

Ensure that the log file and directory are accessible by the monitoring agent.

  • chmod 755 on the log file directories
  • chmod 744 or similar on the log files

Note: If you use something like logrotate, be sure to specify the permissions (mode) of the new log file that is created after rotating the old log file out and replacing it.

Configure Applications

Depending on your setup, use either Auto Discovery or Manual Configuration.

Auto Discovery

Auto Discovery option will scan a set of predefined directories for Apache access logs:

  • /var/log/apache2
  • /var/log/apache
  • /var/log/httpd
  • /etc/httpd/logs

Auto discovery can be enabled in /usr/local/stackify/stackify-agent/stackify-agent.conf.

discovery.apache=true

This can automatically be enabled with the Linux Installer argument --discovery-apache.

Manual Configuration

Use Manual Configuration if auto discovery does not find your access logs or you want to define specific Application and Environment labels.

Configuration should be added to: /usr/local/stackify/stackify-agent/stackify-agent.conf.

For each access log setup the following parameters, [application] should be replaced w/ a unique key to group the configuration items together.

stackify.apache.[application].app=Sample Application
stackify.apache.[application].env=Production
stackify.apache.[application].accessLog=/var/log/custom/apache/access.log
Was This Article Helpful?