Answers.Body: <ol>
  <li>Create a plugin (<a href="https://docs.craftcms.com/v2/plugins/introduction.html" rel="nofollow noreferrer">https://docs.craftcms.com/v2/plugins/introduction.html</a>,  <a href="https://pluginfactory.io/" rel="nofollow noreferrer">https://pluginfactory.io/</a>)</li>
  <li>Create a Variable class with a log function (<a href="https://docs.craftcms.com/v2/plugins/variables.html" rel="nofollow noreferrer">https://docs.craftcms.com/v2/plugins/variables.html</a>)</li>
  <li>Pass data from getFlashes to your function from within the template like e.g. <code>craft.yourPluginName.yourVariableFunctionName(craft.session.getFlashes)</code></li>
  </ol>
  
  <p>Tip: Use YourPluginName::log('blabla' . $string); to log anything to /storage/runtime/logs/yourpluginname.log from within your Plugin</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-17T14:56:12.420Z
Answers.LastActivityDate: 2019-01-17T14:56:12.420Z
Answers.UserDisplayName: phaetons
Body: <p>I need to log flash messages from <code>craft.session.getFlashes</code> to a error log file from a particular twig template in Craft 2. Is there a way to do it ? </p>
  
Tags: <craft2>
Title: Log Errors from twig template
ThreadText: # Log Errors from twig template
  
  (Asked by: username_0 on 2019-01-17)
  
  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 ?
  
  **Tags:** craft2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-01-17. Score: 1 | Accepted answer
  
  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
  
  
  ---
  
  