Logging Configuration
The logging.php
file contains log file configuration items. This document provides an list of configuration items available in the file, allowing you to modify them as necessary.
Contents
For details on how to set the below configuration items, please create a /config/production/logging.php
file and read: Updating Config Files.
Log Channels
The relevant channels to edit are:
emaillog
- the verbose email log, which has to be enabled under the email channel settings.querylog
- all SQL queries, which are only stored when debug mode is manually enabled in the app configuration file.generallog
- the application log files.
Name | Description | Valid values | Default |
---|---|---|---|
max_files |
The number of log files to retain. | integer |
3 or 5 |
level |
Log all levels greater than or equal to the specified severity level. For example, a log_level of error will log error, critical, alert, and emergency messages. |
debug, info, notice, warning, error, critical, alert, emergency |
info |
Slack Notifications
It's possible to simultaneously write to both the traditional log files above and also to Slack. This can be a great way to allow your engineers to act quickly in the event of application errors.- Create an incoming web hook for your Slack channel, see https://api.slack.com/messaging/webhooks#getting_started.
- Make note of the incoming web hook URL, we'll need this later on.
- Create a
config/production/logging.php
file. - Paste the below contents, replacing
INCOMING_WEBHOOK
with the URL from step 2 above, and save the file:
<?php return [ 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['generallog', 'slack'], 'ignore_exceptions' => false, ], 'slack' => [ 'driver' => 'slack', 'url' => 'INCOMING_WEBHOOK', 'username' => 'SupportPal Log', 'emoji' => ':boom:', 'level' => 'error', 'short' => true, 'context' => false, ], 'generallog' => [ 'driver' => 'custom', 'via' => \App\Logging\GeneralLogger::class, 'max_files' => 5, 'level' => 'info' ] ], ];
Once complete, every time a production.ERROR
is written to the log it will also be sent to your Slack channel.
You can toggle the short
and context
variables depending on whether you want the full stack trace to be written.
We suggest to disable this because it can generate a lot of spam in the channel.