Server logs

All Cloud 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 Cloud username (see your profile) and password, at the following URL:

https://logs.silverstripe.cloud/

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

Cloud 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 an 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 virtual stacks, 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

In addition to the standard logging events from Apache, PHP etc, you may wish to send some of your own messages to Graylog. Sending custom messages to Graylog from different execution paths in your codebase can be key in debugging bugs or other issues.

Logging custom events in Silverstripe CMS

Create a new yml file in your _config directory, for most applications this will be in app/_config, with the following content:

---
Name: sysloglogging
---
SilverStripe\Core\Injector\Injector:
  Psr\Log\LoggerInterface:
    calls:
      pushSilverStripeSyslogHandler: [ pushHandler, [ '%$Monolog\Handler\HandlerInterface.silverstripe' ] ]
  # Internal error handler, piped to syslog which is routed to Graylog
  Monolog\Handler\HandlerInterface.silverstripe:
    class: Monolog\Handler\SyslogHandler
    constructor:
      - 'SilverStripe_log'

You can now follow this guide to send custom messages to Graylog.

For more information, see logging in Silverstripe CMS documentation.

Was this answer helpful? Yes No

Sorry we couldn't be helpful. Help us improve this article with your feedback.