title: Logging design pattern in a Zend framework application
body: <p>I'm building an application using Zend Framework. The application requires intensive logging for every action or function in the code.</p>
  
  <p>so my code most of the time looks like this:</p>
  
  <pre><code>function SendMailsAction(){
        $logger-&gt;log('Started sending mails.')
  ...
  ...
  ...Some Code...
  ...
  ...
  
  foreach ($mails as $mail){
    try{      
         $logger-&gt;log('Trying to send')
         $mail-&gt;send()
         $logger-&gt;log('Mail sent successfully.')
    }catch(Exception $e){
         $logger-&gt;log('Failed to send mail.')
        }      
   }
  
  ...
  ...
  ...Some Code...
  ...
  ...
         $logger-&gt;log('Finished sending mails.')
  }
  </code></pre>
  
  <p>Sometimes I even have to log in 2 tables, so most of the logging code is doubled and the functions start to get complicated and long.</p>
  
  <p>I use Zend framework's <code>Zend_Log</code> for logging so my problem is not the logging class itself, But it's how to separate the logging code from the code functionality itself and maintain separation of concerns.</p>
  
  <p>Some people suggested Aspect Oriented  Programming (AOP), but unfortunately AOP for PHP isn't acceptable for my costumer, so I'm looking for an Object Oriented solution or best practice.</p>
  
  <p>Note:</p>
  
  <p>Just to make things clear my problem isn't how to use <code>Zend_Log</code>, but how to add logging to my application code in general.</p>