SlideShare a Scribd company logo
1 of 13
Download to read offline
Developer Fundamentals

              LOGGING

                    BY
AXEL IRRIGER (HTTP://WWW.AXELIRRIGER.DE)
                MAY, 2010
Agenda

 About Myself

 What Is Logging?
     Storyboard
     Analysis
     Definition

 Why Do We Want To Log Things?

 How Do We Do Logging?
     Logically
     Technically
About Myself

 Software/Solution Architect with a consulting
  company in Germany

 Dealing with software since the age of 10
     Atari ST … Basic, Assembler, Pascal

 Primarily dealing with Java and Python nowadays
     EAI, SOA, BPM
     JBossAS 4 and JBossAS 5
     Apache ServiceMix, jBPM, JBoss Rules
     …

 Passion
     Software Quality
     Excellence in Craftsmanship

 Drop me a message axel (dot) irriger (at) gmail (dot) com
What Is Logging? - Storyboard

John and Will are software developers. They are both
  experienced and get things done, literary speaken.

On a tough assignment, they get errors and the software
 does not, what it should. Since they both short on
 schedule, they need to get that error fixed quickly, to not
 burn the deadline to ashes.

What will they do?
What Is Logging? –John‘s Way

John automatically fires up his favorite debugger and
  starts digging around the code, where it expects the
  error to be.
After some hours passing, digging here, poking there,
  he located the error and got it fixed.
It was in a different module than he first expected –
  but who cares, the job is done and the clock shows
  11pm.
What Is Logging? –Will‘s Way

Will gets curious – why in hell must this happen know? But it is, as it
 is. So, he fires up his IDE and reconfigures the logging system to
 „debug“ and starts the application again.

After some 5-10 minutes looking through the log files, he gets curious
  – there‘s something wrong in this XYZ module. Though he doesn‘t
  know what.
So, he again reconfigures the logging system again to „trace“ and
  starts his run again. Filtering out the logs pretty quickly he sees that
  gets wrong … that parameter should look different!
He fixes the issue and starts again – everything‘s fine now.

It‘s 6pm, a little late, but just in time for dinner.
What Is Logging? – Analysis

 John did not care about logging – it just takes time and
  gets you nothing. That cost him time, overall

 Will did care about logging, to be able to fix things faster
   Logging helped him see, what the application did

   He could locate the issue at hand more quickly and pin down the
    suspected piece of code
   He needed not do any intense digging but just read output
What Is Logging? – Definition

 Logging is about letting the program speak what it does
 Using fine-grained thresholds, from the most generic to
 the most detailed information, information is written to a
 log

 Logging is the process of noting down processing steps to
 document
    What is done
    With what data it is done
    What the outcome is
Why Do We Want To Log Things?

 Understanding and Documentation
   Being able to provide good logging helps yourself to better
    understand the code
   Reading through log messages helps new developers to more easily
    grasp your intentions
 Bug fixing
   Detect errors more easily
   Detect strange variable values more easily
   Find the error vs. Look for the error

 Support
   Really want to do endless iterations with a customer, or just get the
    logs and start working?
How Do We Do Logging? - Logically

 What to log?
   Method/Function entry and exist  You want to know where
    the program walks along
   General information like starting, stopping, configuring  You
    want to see the „big picture“ of the program
   External information and computations  You want explicitly
    see what can‘t be seen (RDBMS input, run-timecomputations,
    etc.)
   Parameters passed  You want to see, how things happened
    and why
 Log frameworks offer granularity – use it
How Do We Do Logging? - Logically

 How should levels be used?
    FATAL  everything which stops the program from continuing (no
     RDBMS, unable to read system files)
    ERROR  everything which is erroneous, but does not stop te
     program from continuing (Mail adresses not found, so no mailing)
    WARN  If defaults are used, because no configuration was passed
     and things like that
    INFO  General informations
    DEBUG  External informations, Control-Flow decisions
    TRACE  Method/Function entry/exit, Parameters


 Use this as a convention until you feel comfortable
 When you‘re comfortable, adjust to your habbits
How Do We Do Logging? - Technically

 Decide on the framework and stick to that
     java.util.logging – Provided out of the box
     Apache log4j (log4j) – The widest usage
     Apache Commons::Logging (commons-logging) – Abstraction layer for other frameworks
     Simple Logging Facade for Java (slf4j) – Simpler abstraction layer for other frameworks

 Get familiar to your framework
     How to use categories to filter things
     How to filter out unimportant stuff
     How to use appenders to utilize different log files
     How to use loggers to support Console, File, SMTP, SNMP, ...

 Always use something like „isDebugEnabled“ or „isLevelEnabled“
     Don‘t even try to log something if it wouldn‘t be written
         LOG.debug huge messages with „debug“ disabled has huge performance impact
         Message will be serialized (costly) and then skipped!
Summary

 We have seen why logging is worth a consideration
 We have seen why we want to do logging at all
 We have seen how logging should be approached
  logically („from the brain“)
 We have seen how logging should be approached
  technically („from the keyboard“)

 Various logging frameworks will be discussed in ongoing
 sessions
              Get out and your hands dirty!

More Related Content

Similar to Developer Fundamentals - Logging

Functional node.js
Functional node.jsFunctional node.js
Functional node.js
Carob Cherub
 
Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
Clay Helberg
 
Linux multiplexing
Linux multiplexingLinux multiplexing
Linux multiplexing
Mark Veltzer
 

Similar to Developer Fundamentals - Logging (20)

WoMakersCode 2016 - Shit Happens
WoMakersCode 2016 -  Shit HappensWoMakersCode 2016 -  Shit Happens
WoMakersCode 2016 - Shit Happens
 
Functional node.js
Functional node.jsFunctional node.js
Functional node.js
 
Become a Better Developer with Debugging Techniques for Drupal (and more!)
Become a Better Developer with Debugging Techniques for Drupal (and more!)Become a Better Developer with Debugging Techniques for Drupal (and more!)
Become a Better Developer with Debugging Techniques for Drupal (and more!)
 
Functional and non functional application logging
Functional and non functional application loggingFunctional and non functional application logging
Functional and non functional application logging
 
MojoPortal And Log4net
MojoPortal And Log4netMojoPortal And Log4net
MojoPortal And Log4net
 
TDC 2015 - POA - Trilha PHP - Shit Happens
TDC 2015 - POA - Trilha PHP - Shit HappensTDC 2015 - POA - Trilha PHP - Shit Happens
TDC 2015 - POA - Trilha PHP - Shit Happens
 
Introduce Django
Introduce DjangoIntroduce Django
Introduce Django
 
Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
 
Data analysis with pandas
Data analysis with pandasData analysis with pandas
Data analysis with pandas
 
Data Analysis With Pandas
Data Analysis With PandasData Analysis With Pandas
Data Analysis With Pandas
 
How to Use OWASP Security Logging
How to Use OWASP Security LoggingHow to Use OWASP Security Logging
How to Use OWASP Security Logging
 
Linux multiplexing
Linux multiplexingLinux multiplexing
Linux multiplexing
 
Kibana+ElasticSearch+LogStash to handle Log messages on Prod servers
Kibana+ElasticSearch+LogStash to handle Log messages on Prod serversKibana+ElasticSearch+LogStash to handle Log messages on Prod servers
Kibana+ElasticSearch+LogStash to handle Log messages on Prod servers
 
Six Mistakes of Log Management 2008
Six Mistakes of Log Management 2008Six Mistakes of Log Management 2008
Six Mistakes of Log Management 2008
 
Php rules
Php rulesPhp rules
Php rules
 
12 tricks to avoid hackers breaks your CI / CD
12 tricks to avoid hackers breaks your  CI / CD12 tricks to avoid hackers breaks your  CI / CD
12 tricks to avoid hackers breaks your CI / CD
 
Fp201 unit1 1
Fp201 unit1 1Fp201 unit1 1
Fp201 unit1 1
 
How to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production ServicesHow to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
 
PHP - Introduction to PHP Bugs - Debugging
PHP -  Introduction to  PHP Bugs - DebuggingPHP -  Introduction to  PHP Bugs - Debugging
PHP - Introduction to PHP Bugs - Debugging
 
Php rules
Php rulesPhp rules
Php rules
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Developer Fundamentals - Logging

  • 1. Developer Fundamentals LOGGING BY AXEL IRRIGER (HTTP://WWW.AXELIRRIGER.DE) MAY, 2010
  • 2. Agenda  About Myself  What Is Logging?  Storyboard  Analysis  Definition  Why Do We Want To Log Things?  How Do We Do Logging?  Logically  Technically
  • 3. About Myself  Software/Solution Architect with a consulting company in Germany  Dealing with software since the age of 10  Atari ST … Basic, Assembler, Pascal  Primarily dealing with Java and Python nowadays  EAI, SOA, BPM  JBossAS 4 and JBossAS 5  Apache ServiceMix, jBPM, JBoss Rules  …  Passion  Software Quality  Excellence in Craftsmanship  Drop me a message axel (dot) irriger (at) gmail (dot) com
  • 4. What Is Logging? - Storyboard John and Will are software developers. They are both experienced and get things done, literary speaken. On a tough assignment, they get errors and the software does not, what it should. Since they both short on schedule, they need to get that error fixed quickly, to not burn the deadline to ashes. What will they do?
  • 5. What Is Logging? –John‘s Way John automatically fires up his favorite debugger and starts digging around the code, where it expects the error to be. After some hours passing, digging here, poking there, he located the error and got it fixed. It was in a different module than he first expected – but who cares, the job is done and the clock shows 11pm.
  • 6. What Is Logging? –Will‘s Way Will gets curious – why in hell must this happen know? But it is, as it is. So, he fires up his IDE and reconfigures the logging system to „debug“ and starts the application again. After some 5-10 minutes looking through the log files, he gets curious – there‘s something wrong in this XYZ module. Though he doesn‘t know what. So, he again reconfigures the logging system again to „trace“ and starts his run again. Filtering out the logs pretty quickly he sees that gets wrong … that parameter should look different! He fixes the issue and starts again – everything‘s fine now. It‘s 6pm, a little late, but just in time for dinner.
  • 7. What Is Logging? – Analysis  John did not care about logging – it just takes time and gets you nothing. That cost him time, overall  Will did care about logging, to be able to fix things faster  Logging helped him see, what the application did  He could locate the issue at hand more quickly and pin down the suspected piece of code  He needed not do any intense digging but just read output
  • 8. What Is Logging? – Definition  Logging is about letting the program speak what it does  Using fine-grained thresholds, from the most generic to the most detailed information, information is written to a log  Logging is the process of noting down processing steps to document  What is done  With what data it is done  What the outcome is
  • 9. Why Do We Want To Log Things?  Understanding and Documentation  Being able to provide good logging helps yourself to better understand the code  Reading through log messages helps new developers to more easily grasp your intentions  Bug fixing  Detect errors more easily  Detect strange variable values more easily  Find the error vs. Look for the error  Support  Really want to do endless iterations with a customer, or just get the logs and start working?
  • 10. How Do We Do Logging? - Logically  What to log?  Method/Function entry and exist  You want to know where the program walks along  General information like starting, stopping, configuring  You want to see the „big picture“ of the program  External information and computations  You want explicitly see what can‘t be seen (RDBMS input, run-timecomputations, etc.)  Parameters passed  You want to see, how things happened and why  Log frameworks offer granularity – use it
  • 11. How Do We Do Logging? - Logically  How should levels be used?  FATAL  everything which stops the program from continuing (no RDBMS, unable to read system files)  ERROR  everything which is erroneous, but does not stop te program from continuing (Mail adresses not found, so no mailing)  WARN  If defaults are used, because no configuration was passed and things like that  INFO  General informations  DEBUG  External informations, Control-Flow decisions  TRACE  Method/Function entry/exit, Parameters  Use this as a convention until you feel comfortable  When you‘re comfortable, adjust to your habbits
  • 12. How Do We Do Logging? - Technically  Decide on the framework and stick to that  java.util.logging – Provided out of the box  Apache log4j (log4j) – The widest usage  Apache Commons::Logging (commons-logging) – Abstraction layer for other frameworks  Simple Logging Facade for Java (slf4j) – Simpler abstraction layer for other frameworks  Get familiar to your framework  How to use categories to filter things  How to filter out unimportant stuff  How to use appenders to utilize different log files  How to use loggers to support Console, File, SMTP, SNMP, ...  Always use something like „isDebugEnabled“ or „isLevelEnabled“  Don‘t even try to log something if it wouldn‘t be written  LOG.debug huge messages with „debug“ disabled has huge performance impact  Message will be serialized (costly) and then skipped!
  • 13. Summary  We have seen why logging is worth a consideration  We have seen why we want to do logging at all  We have seen how logging should be approached logically („from the brain“)  We have seen how logging should be approached technically („from the keyboard“)  Various logging frameworks will be discussed in ongoing sessions Get out and your hands dirty!