Is there any way to create a custom log in Craft? I need to log some actions inside a controller/service in a custom plugin.


You can do this in your plugin:

ExamplePlugin::log('the is the log message');

the log method has the following signature:

log($msg, $level = LogLevel::Info, $force = false)

documentation is here

your log will appear in the app/storage/runtime/logs/pluginname.log

  • Do i have to create any class for this to work?
    – mbalparda
    Oct 3 '14 at 12:05
  • 1
    if you have a custom plugin your will already have a main plugin class in the root of your plugin folder like ExamplePlugin.php this class will extend BasePlugin and thus get the static log function Oct 3 '14 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.