SlideShare a Scribd company logo
Java Logging Frameworks
      Demystified



           By
       Jumping Bean
         21 May 2012
Who Am I?

    Mark Clarke – Java Developer

    Working for Jumping Bean, an open source
    solutions integration company

    Working with Java & open source
    technologies since 2001

    Co-founder of Jozi JUG
Jozi JUG
Jozi JUG

    Meet once a month in Johannesburg,

    Talk

    Beer

    Pizza

    All FREE!

    Where to find us?
           −   Meetup
           −   Facebook
           −   Web Site
Why Log?

    Needed during development to identify errors,

    Needed during production for troubleshooting,
Requirements for a Logging
            Framework

    Logging should be easy for the developer to
    use,

    Logging should be flexible,

    Logging setup/config should be easy,
    especially for system administrators

    Configuration should be done at runtime,

    Framework should free you up to concentrate
    on the business/application logic
Reality of Logging Framework

    BUT
      −    Logging frameworks are difficult to
           understand,
      −    Logging frameworks are difficult to configure
      −    Lots of heat but not much light when
           searching the Interwebs

    Why?
      −    Competing frameworks,
             
                 Part of Java community culture
      −    Over engineered?
Why So Complex?

    Why are logging frameworks so complex?
       −   Filtering of log messages to extract
           messages that meet system admin defined
           criteria,
       −   Writing of a single log message to multiple
           destination,
       −   Formatting log messages for different log
           back-ends such as text files, databases,
           email etc.
       −   Ensuring logging has minimal impact on
           performance,
Why So Complex?
−   Integrating 3r party libraries with their own
    logging requirements,
−   Allowing for the runtime selection of logging
    frameworks,
−   Allowing for runtime configuration of the
    selected logging framework,
−   Applications are distributed
Well Known Java Logging
             Frameworks

    Log4j - The progenitor of all logging
    frameworks

    java.util.logging- The usurper. Attempted to
    add log4j to the Java JDK & improve on it.

    Jakarta Commons Logging - The failed
    abstractor. attempted to allow the underlying
    logging framework to be determined by the
    system administrator deploying the application
Well Known Java Logging
             Frameworks

    Simple Logging Façade for Java           -The
    great abstractor. Some would call slf4j the
    saviour of Java logging. It is largely successful
    at abstracting away the underlying logging
    framework, allowing for it to be change at
    runtime with relative ease.

    Logback -The return of the jedi - This is the
    successor to the great progenitor log4j. Looks
    promising.
Other Java Logging Frameworks

    Even more logging frameworks, over 20!


    http://java-source.net/open-source/logging
What's missing?



  A conceptual model
Conceptual Model

    Logging Entities

    Interaction between entities

    Each framework has variations on the model
Conceptual Model

    Logging Entities

    Interaction between entities
Logging Entities
Entity                         Description
Log Manager                    Access point to logging system
Log Message/Log Entry          The log message
Severity/Level                 A ranking of the log messages, also used
                               as a filter criteria
Logger                         A processing unit for the log message
Appenders/Handlers             A target to send the log message to
Filters                        Criteria used to filter message
Formatters/Renderers/Layouts   Formatting of the log message for its
                               handler/appender
Log Manager

    Global object to access logging system,

    Used to create or retrieve
        −   Loggers
        −   Handlers
        −   Filters
        −   Appenders
        −   etc
Log Message

    The application message you wish to log.

    Can do things like:
        −   Replace parameters at logging time,
        −   Convert objects into string representations
            etc.

    Log messages have a severity attached to
    them

    Log messages are sent to a single Logger
Severity/Level

    Classification of the Log Message.

    Organised in a hierarchy of severity

    Lower level include higher level messages
Logger

    A logger is conceptually like a message queue

    A logger “processes” a log message

    Loggers are identified by string names

    Loggers are in a hierarchy determined
    identifier.

    Logger hierarchy set by “.” in logger identifier
Logger

    Every Logger has a parent,

    Root Logger is top of the logger hierarchy and
    always exists

    Loggers are source of complexity as Log
    messages “bubble up” the hierarchy

    Loggers can have severity levels to filter
    incoming log messages
Appenders/Handlers

    Represents a destination for a log method
    once it has been accepted by a Logger,

    Loggers can have more than one appender

    An appender can belong to more than one
    logger

    Appenders can be anything
       −   Database
       −   Text file
       −   Console
       −   Email
Filters

    A filter is a criteria against which incoming log
    messages are compared to be processed or
    discarded

    Filters can be on Loggers in some cases

    Filters can be on appenders,

    A filter can be attached to more than one
    appender/logger
Formatters/Layouts

    These entities format a log message for their
    assigned appenders,

    Add information to the log message like
    timestamp, class information etc

    Formatters/Layouts usually depend on the
    type of the appender
Sequence Diagram
How Log Messages Bubble Up

    Log messages received by a Logger and
    passed up the Logger hierarchy

    The exact flow varies from framework to
    framework

    Source of much confusion
       −   Unwanted log messages in appenders,
Java logging
Java logging
Configuration

    Configuration can be done at compile time in
    code

    At runtime with configuration files

    At runtime via JMX
Meta Loggers

    Frameworks to abstract away Logging
    frameworks,

    Allow for run time changing of logging
    frameworks,

    Apache Commons Logging – not used due to
    architectural issues,

    Sl4j – Best meta logging framework
Meta Loggers

    SL4J allows for code to be written without
    concern for underlying framework
        −   Change deployed jars to target different
            frameworks

    SL4J – allows for bridging of disparate logging
    frameworks in 3rd party libraries used in your
    application
Java Logging Frameworks




         The End

More Related Content

PPTX
Introduction to Spring Framework
PPTX
Java Logging
PPT
Java Persistence API (JPA) Step By Step
PPTX
Entity framework code first
PDF
Spring annotation
PPTX
What is Swagger?
PDF
Nodejs presentation
PPTX
Java 8 Lambda and Streams
Introduction to Spring Framework
Java Logging
Java Persistence API (JPA) Step By Step
Entity framework code first
Spring annotation
What is Swagger?
Nodejs presentation
Java 8 Lambda and Streams

What's hot (20)

PPT
PDF
Spring Framework - Core
ODP
Introduction to Apache solr
PPTX
Java Spring Framework
PDF
Java 8 Lambda Expressions & Streams
PDF
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
PDF
Spring Framework - MVC
PPT
WebLogic Scripting Tool Overview
PPTX
Introduction to GraphQL
PDF
Spring Data JPA
PDF
PUC SE Day 2019 - SpringBoot
PPTX
An Introduction To REST API
PPTX
Rest api with node js and express
PPTX
Log4j slideshare
PPTX
Java Lambda Expressions.pptx
PPT
Spring Boot in Action
PDF
Java8 features
PDF
JavaFX Overview
PPSX
Spring - Part 1 - IoC, Di and Beans
PPT
Developing an ASP.NET Web Application
Spring Framework - Core
Introduction to Apache solr
Java Spring Framework
Java 8 Lambda Expressions & Streams
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Framework - MVC
WebLogic Scripting Tool Overview
Introduction to GraphQL
Spring Data JPA
PUC SE Day 2019 - SpringBoot
An Introduction To REST API
Rest api with node js and express
Log4j slideshare
Java Lambda Expressions.pptx
Spring Boot in Action
Java8 features
JavaFX Overview
Spring - Part 1 - IoC, Di and Beans
Developing an ASP.NET Web Application
Ad

Viewers also liked (11)

PPTX
SLF4J+Logback
PPT
Log4j Logging Mechanism
PPTX
Functional and non functional application logging
PPTX
SLF4J Explained........
PDF
Exception handling & logging in Java - Best Practices (Updated)
PPTX
The Ultimate Logging Architecture - You KNOW you want it!
PPTX
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
PPSX
Tips on how to defend your thesis
PPTX
Thesis Power Point Presentation
PPSX
Conceptual and theoretical framework
SLF4J+Logback
Log4j Logging Mechanism
Functional and non functional application logging
SLF4J Explained........
Exception handling & logging in Java - Best Practices (Updated)
The Ultimate Logging Architecture - You KNOW you want it!
Elasticsearch, Logstash, Kibana. Cool search, analytics, data mining and more...
Tips on how to defend your thesis
Thesis Power Point Presentation
Conceptual and theoretical framework
Ad

Similar to Java logging (20)

PPT
PPT
PDF
Logging Application Behavior to MongoDB
PDF
Developer Fundamentals - Logging
PPTX
Logging and Exception
PDF
Rein_in_the_ability_of_log4j
PDF
Log4j in 8 slides
PPT
Log4 J
PPTX
Log4j is a reliable, fast and flexible
ODP
Logging with Logback in Scala
PDF
DOCX
JAVA LOGGING for JAVA APPLICATION PERFORMANCE
PDF
Log4c developersguide
PPTX
Build, logging, and unit test tools
PDF
Helpful logging with Java
PDF
World of Logging
PDF
Java Abs Java Productivity Creator & Analyzer
Logging Application Behavior to MongoDB
Developer Fundamentals - Logging
Logging and Exception
Rein_in_the_ability_of_log4j
Log4j in 8 slides
Log4 J
Log4j is a reliable, fast and flexible
Logging with Logback in Scala
JAVA LOGGING for JAVA APPLICATION PERFORMANCE
Log4c developersguide
Build, logging, and unit test tools
Helpful logging with Java
World of Logging
Java Abs Java Productivity Creator & Analyzer

More from Jumping Bean (15)

PDF
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
PDF
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
PDF
React - The JavaScript Library for User Interfaces
PDF
IPv6 How To Set Up a Linux IPv6 Lan
PDF
HTML 5 & The Modern Web
PDF
Building games-with-libgdx
PDF
Linux Containers & Docker
PDF
Introduction to Web Sockets
PDF
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South Africa
PDF
M-Learning application development with open source
PDF
Introduction to AngularJS
PDF
Introduction to Android Development
PDF
Glassfish An Introduction
PDF
IPv6 - Jozi Linux User Group Presentation
PDF
SELinux Johannesburg Linux User Group (JoziJUg)
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
React - The JavaScript Library for User Interfaces
IPv6 How To Set Up a Linux IPv6 Lan
HTML 5 & The Modern Web
Building games-with-libgdx
Linux Containers & Docker
Introduction to Web Sockets
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South Africa
M-Learning application development with open source
Introduction to AngularJS
Introduction to Android Development
Glassfish An Introduction
IPv6 - Jozi Linux User Group Presentation
SELinux Johannesburg Linux User Group (JoziJUg)

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
1. Introduction to Computer Programming.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
Machine Learning_overview_presentation.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Tartificialntelligence_presentation.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Electronic commerce courselecture one. Pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Machine learning based COVID-19 study performance prediction
Building Integrated photovoltaic BIPV_UPV.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Programs and apps: productivity, graphics, security and other tools
1. Introduction to Computer Programming.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Machine Learning_overview_presentation.pptx
MYSQL Presentation for SQL database connectivity
Tartificialntelligence_presentation.pptx
A Presentation on Artificial Intelligence
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Electronic commerce courselecture one. Pdf
Empathic Computing: Creating Shared Understanding
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Java logging

  • 1. Java Logging Frameworks Demystified By Jumping Bean 21 May 2012
  • 2. Who Am I?  Mark Clarke – Java Developer  Working for Jumping Bean, an open source solutions integration company  Working with Java & open source technologies since 2001  Co-founder of Jozi JUG
  • 4. Jozi JUG  Meet once a month in Johannesburg,  Talk  Beer  Pizza  All FREE!  Where to find us? − Meetup − Facebook − Web Site
  • 5. Why Log?  Needed during development to identify errors,  Needed during production for troubleshooting,
  • 6. Requirements for a Logging Framework  Logging should be easy for the developer to use,  Logging should be flexible,  Logging setup/config should be easy, especially for system administrators  Configuration should be done at runtime,  Framework should free you up to concentrate on the business/application logic
  • 7. Reality of Logging Framework  BUT − Logging frameworks are difficult to understand, − Logging frameworks are difficult to configure − Lots of heat but not much light when searching the Interwebs  Why? − Competing frameworks,  Part of Java community culture − Over engineered?
  • 8. Why So Complex?  Why are logging frameworks so complex? − Filtering of log messages to extract messages that meet system admin defined criteria, − Writing of a single log message to multiple destination, − Formatting log messages for different log back-ends such as text files, databases, email etc. − Ensuring logging has minimal impact on performance,
  • 9. Why So Complex? − Integrating 3r party libraries with their own logging requirements, − Allowing for the runtime selection of logging frameworks, − Allowing for runtime configuration of the selected logging framework, − Applications are distributed
  • 10. Well Known Java Logging Frameworks  Log4j - The progenitor of all logging frameworks  java.util.logging- The usurper. Attempted to add log4j to the Java JDK & improve on it.  Jakarta Commons Logging - The failed abstractor. attempted to allow the underlying logging framework to be determined by the system administrator deploying the application
  • 11. Well Known Java Logging Frameworks  Simple Logging Façade for Java -The great abstractor. Some would call slf4j the saviour of Java logging. It is largely successful at abstracting away the underlying logging framework, allowing for it to be change at runtime with relative ease.  Logback -The return of the jedi - This is the successor to the great progenitor log4j. Looks promising.
  • 12. Other Java Logging Frameworks  Even more logging frameworks, over 20!  http://java-source.net/open-source/logging
  • 13. What's missing? A conceptual model
  • 14. Conceptual Model  Logging Entities  Interaction between entities  Each framework has variations on the model
  • 15. Conceptual Model  Logging Entities  Interaction between entities
  • 16. Logging Entities Entity Description Log Manager Access point to logging system Log Message/Log Entry The log message Severity/Level A ranking of the log messages, also used as a filter criteria Logger A processing unit for the log message Appenders/Handlers A target to send the log message to Filters Criteria used to filter message Formatters/Renderers/Layouts Formatting of the log message for its handler/appender
  • 17. Log Manager  Global object to access logging system,  Used to create or retrieve − Loggers − Handlers − Filters − Appenders − etc
  • 18. Log Message  The application message you wish to log.  Can do things like: − Replace parameters at logging time, − Convert objects into string representations etc.  Log messages have a severity attached to them  Log messages are sent to a single Logger
  • 19. Severity/Level  Classification of the Log Message.  Organised in a hierarchy of severity  Lower level include higher level messages
  • 20. Logger  A logger is conceptually like a message queue  A logger “processes” a log message  Loggers are identified by string names  Loggers are in a hierarchy determined identifier.  Logger hierarchy set by “.” in logger identifier
  • 21. Logger  Every Logger has a parent,  Root Logger is top of the logger hierarchy and always exists  Loggers are source of complexity as Log messages “bubble up” the hierarchy  Loggers can have severity levels to filter incoming log messages
  • 22. Appenders/Handlers  Represents a destination for a log method once it has been accepted by a Logger,  Loggers can have more than one appender  An appender can belong to more than one logger  Appenders can be anything − Database − Text file − Console − Email
  • 23. Filters  A filter is a criteria against which incoming log messages are compared to be processed or discarded  Filters can be on Loggers in some cases  Filters can be on appenders,  A filter can be attached to more than one appender/logger
  • 24. Formatters/Layouts  These entities format a log message for their assigned appenders,  Add information to the log message like timestamp, class information etc  Formatters/Layouts usually depend on the type of the appender
  • 26. How Log Messages Bubble Up  Log messages received by a Logger and passed up the Logger hierarchy  The exact flow varies from framework to framework  Source of much confusion − Unwanted log messages in appenders,
  • 29. Configuration  Configuration can be done at compile time in code  At runtime with configuration files  At runtime via JMX
  • 30. Meta Loggers  Frameworks to abstract away Logging frameworks,  Allow for run time changing of logging frameworks,  Apache Commons Logging – not used due to architectural issues,  Sl4j – Best meta logging framework
  • 31. Meta Loggers  SL4J allows for code to be written without concern for underlying framework − Change deployed jars to target different frameworks  SL4J – allows for bridging of disparate logging frameworks in 3rd party libraries used in your application