Looking for Craft 2 Support? OneLogger for Craft 2
This plugin writes logs to php://stderr
for Heroku hosting.
This plugin requires Craft CMS 3.0.0-beta.23 or later.
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/onedesign/onelogger"
}
],
"require": {
"onedesign/onelogger": "^2.0",
}
}
composer update onedesign/onelogger
- In the Control Panel, go to Settings → Plugins and click the “Install” button for onelogger.
You can configure the log levels that show up in the stderr logs by adding a onelogger.php
config file (and an ENV var).
config/onelogger.php
<?php
return [
'logLevels' => getenv('ONELOGGER_LOG_LEVELS') ? explode(',', getenv('ONELOGGER_LOG_LEVELS')) : ['warning', 'error']
];
.env
# Set which Craft log levels you want to see in stderr
ONELOGGER_LOG_LEVELS="warning,error,info,trace,profile"
Log events in Craft as you normally would (eg Craft::log('Uh oh! Error!', LogLevel::Error)
or MyPlugin::log(...)
), and you'll see the logs in STDOUT.
For example, if you are using Heroku, you can see logs from the command line using:
heroku logs --tail -a app-name
You'll continue seeing logs using Craft's normal filesystem logs. If you're hosting on Heroku, this are ephemeral and will disappear.