Error Logging
All errors that occur during the operation of the application are recorded in the application's log files in the directory:
/files/logs/
The application's log files that can be found in this directory are as follows:
- bills.log - errors that occur during the activation of paid services and payment acceptance
- cron.log - a log that records the operation of cron manager processes
- errors.log - the main application error file
- extensions.log - the error file of extensions
- js.log - the javascript error file of the application and extensions
- update.log - a log that records actions performed during the application update process
This list can also be extended depending on the application and modules installed in it.
To log errors during the operation of the application, use the following function call:
bff::log('Error message');
bff::log('Informational message', Logger::INFO);
bff::log(['Message #1', 'Message #2'], Logger::WARNING);
Messages logged in this way will appear in the errors.log file as follows:
[2019-03-22 11:18:51] core.ERROR: Error message
[2019-03-22 11:18:51] core.INFO: Informational message
[2019-03-22 11:18:51] core.WARNING: Array
(
[0] => Message #1
[1] => Message #2
)
You can also pass an array with additional information (context) to further investigate the error:
bff::log('Error message', ['extra'=>1]);
[2019-03-22 11:18:51] core.ERROR: Message {"extra":1}
If necessary, you can specify a custom file to log the error:
bff::log('Error message', 'custom.log');
// or with the message type specified
bff::log('Error message', Logger::DEBUG, 'custom.log');
In this case, a file named /files/logs/custom.log will be created to store the error message. This can be useful when testing a specific function of the application.
The logging mechanism uses the Monolog library, which, in addition to writing to files, can also work with other types of storage.
Extensions
Extensions of the application can also log errors that occur in their own operation. To do this, use the following function call:
$this->log('Error message of the extension');
$this->log('Warning message', Logger::WARNING);
Messages logged in this way will appear in the extensions.log file as follows:
[2019-03-22 11:18:51] plugin.example.ERROR: Error message of the extension
[2019-08-25 13:33:12] plugin.example.WARNING: Warning message
You can also pass an array with additional information (context) to further investigate the error:
$this->log('Error message', ['status'=>1, 'data'=>$data]);
$this->log('Error message', Logger::WARNING, ['data'=>$data]);
Additionally, you can view the list of extension errors in the admin panel in the extension settings section under "Developer / Logs", which is available in developer mode.
System Status
Errors can also occur during the system status check and are logged in the "Site Settings / System Status" section.
For more information on how to manage them, read this section.