1

I need to log flash messages from craft.session.getFlashes to a error log file from a particular twig template in Craft 2. Is there a way to do it ?

1
  1. Create a plugin (https://docs.craftcms.com/v2/plugins/introduction.html, https://pluginfactory.io/)
  2. Create a Variable class with a log function (https://docs.craftcms.com/v2/plugins/variables.html)
  3. Pass data from getFlashes to your function from within the template like e.g. craft.yourPluginName.yourVariableFunctionName(craft.session.getFlashes)

Tip: Use YourPluginName::log('blabla' . $string); to log anything to /storage/runtime/logs/yourpluginname.log from within your Plugin

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.