Logs

This document explains how to work with logs if you are a developer deploying sites to the Platform.

All platform environments send their webserver, system and application logs to a centralised location. These logs are then accessible for several weeks through the Graylog application.

You can access Graylog using your Platform username (see your profile) and password, at the following URL:

https://logs.platform.silverstripe.com/

A Graylog “stream” is provided for each environment you have access to. Streams are filtered views that include only messages coming from one specific environment: they include messages from all web servers, even those that have been cycled out due to autoscaling events or deployments.

Information that can be found in the logs includes, but is not limited to:

  • PHP errors
  • Email logs
  • Apache and nginx access and error logs
  • Custom logs written by the application via SS_Log

Dashboard provides a shortcut link to environment streams too: pick your project from the list and click the “Server logs” link next to the environment.

Searching

For easy start, there is a dropdown with predefined searches in the top-right corner of the Graylog interface. As an example, pick “PHP errors” to see the recent errors on your environment.

To execute a custom search, provide time period and query string. The query string uses Graylog’s query syntax.

Finding virtual environment logs

When using Stack Share, any virtual environment server logs are placed into the same Graylog stream as the base environment where the virtual stack was created.

A field in Graylog called virtual_id can be used to filter the logs to specific virtual environments. For example, this query will only show demosite logs:

virtual_id:demosite

Logging custom events (SilverStripe 3.x)

In addition to the standard logging events from Apache, PHP etc, you may wish to send some of your own messages to Graylog.

The following code in your mysite/_config.php will configure SS_Log to send events to the syslog of the server, which will then be forwarded to Graylog:

if (defined('AWS_SYSLOG_LEVEL')) {
    $sysLogWriter = new SS_SysLogWriter('SilverStripe_log', LOG_PID);
    SS_Log::add_writer($sysLogWriter, (int) AWS_SYSLOG_LEVEL, '<=');
}

Now when you call SS_Log::log() the event will be pushed to Graylog:

SS_Log::log('Something seems to have happened', SS_Log::DEBUG);

You may wish to create your own subclass of SS_LogErrorFileFormatter to format the specific log line that will be sent.

For more information, see logging in SilverStripe documentation.