Valdemar Jordan created LOG4PHP-214:
---------------------------------------

             Summary: New appender for Sentry log aggregation platform
                 Key: LOG4PHP-214
                 URL: https://issues.apache.org/jira/browse/LOG4PHP-214
             Project: Log4php
          Issue Type: Improvement
          Components: Code
            Reporter: Valdemar Jordan
            Priority: Minor


Hi,

Haven't contributed to log4php yet but I have written an appender that writes 
to an instance of Sentry (a Django-based log aggregation system) that I'm 
running. This appender has been running in a production environment for several 
weeks with no known issues. The appender is essentially a wrapper around the 
raven-php library referenced below; the only external dependency is having 
raven-php installed.

Example:

{code}
  *******************************************                                   
                                                                                
                                                                               
* INSTANTIATE RAVEN CLIENT FOR THE LOGGER *                                     
                                                                                
                                                                             
*******************************************                                     
                                                                                
                                                                             
require('libs/Raven/Autoloader.php');                                           
                                                                                
                                                                             
Raven_Autoloader::register();                                                   
                                                                                
                                                                             
$client = new Raven_Client('http://secret1:secret2@sentrybox:9000/666');        
                                                                                
                                                                                
                                                                                
                                                                                
                        

************************                                                        
                                                                                
                                                                             * 
CONFIGURE THE LOGGER *                                                          
                                                                                
                                                                         
************************                                                        
                                                                                
                                                                           
  $logger_config = array(                                                       
                                                                                
                                                                             
    'rootLogger' => array(                                                      
                                                                                
                                                                             
      'level' => 'DEBUG',                                                       
                                                                                
                                                                             
      'appenders' => array('sentry'),                                           
                                                                                
                                                                             
    ),                                                                          
                                                                                
                                                                             
    'appenders' => array(                                                       
                                                                                
                                                                             
      'sentry' => array(                                                        
                                                                                
                                                                             
        'class' => 'LoggerAppenderSentry',                                      
                                                                                
                                                                             
        'params' => array(                    
          'dsn' => $client
        )       
      )
    )
  );
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                              
*************                                                                   
                                                                                
                                                                             * 
LOG STUFF *                                                                     
                                                                                
                                                                           
*************                                                                   
                                                                                
                                                                             
$logger = Logger::getLogger('sentry');                                          
                                                                                
                                                                           
                                                                                
                                                                                
                                                                             
// Log some messages                                                            
                                                                                
                                                                           
$logger->info('Interesting...');                                                
                                                                                
                                                                           
$logger->warn('Watch out!');                                                    
                                                                                
                                                                           
                                                                                
                                                                                
                                                                             
// Log a message with exception (provides backtrace)                            
                                                                                
                                                                           
$logger->fatal('Terrible, just terrible...', new Exception('O NO')); 
{code}

If you guys are interested in adding this to the package let me know what I 
should do to move that along.

References:
https://github.com/getsentry/sentry
https://github.com/getsentry/raven-php



--
This message was sent by Atlassian JIRA
(v6.1.4#6159)

Reply via email to