Collecting Apache Logs
  • Updated on 18 Apr 2019
  • 2 minutes to read
  • Contributors
  • Print
  • Share
  • Dark

Collecting Apache Logs

  • Print
  • Share
  • Dark

The Retrace Monitoring Agent can monitor the health of your Apache web application, including Requests/min vs Average Page Load time, HTTP Request Error Rate, and Apdex Satisfaction Score.

To enable Retrace to monitor your Apache web application from the Monitoring Agent, there are a couple of things to make sure of.

Enable Apache Discovery

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


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

Configuring Apache's apache2.conf Logging Settings

Within apache2.conf or each virtual host config file, you need to make sure there is a separate section representing each site because you will need a separate log file per virtual host. Within each section, you will need to include different components in order for Stackify to correctly discover your web app. Below is a sample virtual host section that will show you the needed items to include.

Sample Section

Above shows the relevant component of the VirtualHost section that is used by Stackify. The following components need to be included within the virtual host section of your Apache configuration file:

  1. DocumentRoot - The root directory for your web apps
  2. ServerName - The name of your site
  3. CustomLog - Specifies the directory for the custom log entry for the Stackify log
  4. ErrorLog - Specifies the directory for the Apache Error log

Note: A LogFormat line will also need to be added somewhere in the Apache config file, whether inside or outside of the virtual host file.

<VirtualHost *:80>
    DocumentRoot /var/www/
    CustomLog /var/log/apache/access_myvhost.log stackify
    ErrorLog /var/log/apache/
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %D" stackify

Sample LogFormat Configuration

An appropriate LogFormat line ensures (at a minimum) that the following fields are captured:

  • time taken
  • first line of request or request path
  • status
  • timestamp

You can add the following line in the Apache config file:

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.

Check Permissions

The final step is to 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.

Was this article helpful?