TL;DR: Use CWP's Graylog - everything is tracked in there already.
Logging has various levels:
class SS_Log
{
const ERR = Zend_Log::ERR;
const WARN = Zend_Log::WARN;
const NOTICE = Zend_Log::NOTICE;
const INFO = Zend_Log::INFO;
const DEBUG = Zend_Log::DEBUG;
These map to a few of the Zend Log constants.
With CWP you get some default logging out of the box:
// Tee logs to syslog to make sure we capture everything regardless of project-specific SS_Log configuration.
SS_Log::add_writer(new \SilverStripe\Auditor\MonologSysLogWriter(), SS_Log::DEBUG, '<=');
This means that everything from debug level will be sent to the syslog by default. This is so the CWP platform can pipe your website logs into Graylog (the centralised logging system), which you can access with your CWP Dash account.
If you need extra logging on top of this, you can configure it in one of two ways:
define('SS_ERROR_LOG', '/path/to/logfile.log')
: This will be automatically configured to write from warning levels up into your log file. This isn't particularly useful to you in the context of CWP because you don't have access to the server to check the files.
- Add your own custom logger and configure it to send logs wherever you want (the example in these docs is an email address).
If you want to enable or disable this with a variable, you only really have the option of adding or removing custom code, since CWP doesn't give you the ability to customise environment variables. You'd need to do a deployment in order to change this code, so you may as well add something like this to mysite/_config.php
and comment it out when you don't need it:
// Log everything and send it to my email address for debugging. Comment out when
// not required.
SS_Log::add_writer(new SS_LogEmailWriter('your-email@example.com'), SS_Log::DEBUG, '<=');
Again, you'll need to do a deployment whenever you change this code though.
Theory aside, my recommendation would be to use the logs that are already available in Graylog.