Go further with your log

Advanced use of Monolog

About myself

  • Jonathan
  • @Grummfy
  • DevOps

Go futher with your logs

Summary

  • Log(s)?
  • Monolog
  • Demo time
  • Questions ?
    • Do it also during the presentation
       
  • I will not speak about
    • ELK (elasticsearch, logstash & kibana)
    • Rsyslog
    • ...

Log(s)?

  • What generates logs?
  • For what purposes?
  • For which usages?
  • One big log or a multitude of logs?
  • So who use logs and for what?

Small definition

Wikipedia can help you!

 

For me :

List of events link to a time (with some messages) and recorded somewhere (usually in a file)

  • Generated by
    • applications
    • infrastructures
    • some external tools : stats, CI, ...
  • Purpose & Usage
    • keep track of events
    • debug
    • security
    • ...
    • linked to your business

Monolog

  • Help with your log
  • Compatible with PSR-3
  • Most known
  • Created by Jordi Boggiano (Seldaek)
    most know for composer

What's in Monolog?

  • Handler
    • to transport
  • Formatter
    • to transform
  • Processor
    • to make log spicy
  • Record
    • event logged

Handler

  • Transport the information to destination
  • Following the level of log: debug -> emergency
  • Some to know
    • StreamHandler
      • log in a file
      • use other stream too
    • NativeMailHandler : log in a mail
    • FingersCrossedHandler : stack until level
    • Tools :
      • RollBarHandler, NewRelicHandler,  ...
      • HipChatHandler, SlackHandler, ...
      • FirePHPHandler, ChromeHandler, ...

Formatter

  • Link to the handler
  • Transform the log event to something understandable by the handler

Processor

  • Link to the handler or the logger itself
  • Add informations to the event
    • Memory usage
    • Request information
    • Environment details
  • Some to know
    • PsrLogMessageProcessor
    • WebProcessor
    • ...

Monolog

Demo time!

Questions?

  • Now
  • @Grummfy
  • grummfy@gmail.com

More information

  • https://github.com/Seldaek/monolog/blob/master/doc/usage.md
  • http://www.php-fig.org/psr/psr-3/
  • https://github.com/Grummfy/Demo-LBM-12-2014

Thanks

Made with Slides.com