SlideShare a Scribd company logo
Albert Guo [email_address]
What is SLF4J? When should SLF4J be used? What are SLF4J's requirements? Parameterized logging Migration Who use SLF4J Demo
The Simple Logging Facade for Java or (SLF4J) serves as a simple facade or abstraction for various logging frameworks, e.g. java.util.logging, log4j and logback, allowing the end user to plug in the desired logging framework at deployment time. http://www.slf4j.org/
SLF4J (Simple Logging Facade for Java)
Suppose that your CRM application uses log4j for its logging. However, one of your important clients request that logging be performed through JDK 1.4 logging.  If your application is riddled with thousands of direct log4j calls, migration to JDK 1.4 would be a relatively lengthy and error-prone process. Even worse, you would potentially need to maintain two versions of your CRM software.  Had you been invoking SLF4J API instead of log4j,  the migration could be completed in a matter of minutes by replacing one jar file with another .
SLF4J (Simple Logging Facade for Java)
Binding Requirements slf4j-nop JDK 1.3 slf4j-simple JDK 1.3 slf4j-log4j12 JDK 1.3, plus any other library dependencies required by the log4j appenders in use slf4j-jdk14 JDK 1.4 or above logback-classic JDK 1.5 or above, plus any other library dependencies required by the logback appenders in use
inefficient style logger.debug("Hello "+name); new style logger.debug("Hello {}", name);
The SLF4J migrator is a small Java tool for migrating Java source files from the Jakarta Commons Logging (JCL) API to SLF4J. It can also migrate from the log4j API to SLF4J, or from java.util.logging API to SLF4J. For further information, please check:  http://www.slf4j.org/migrator.html
Apache Archiva  Apache Directory  Apache FTPServer  Apache Geronimo  Apache Graffito  Apache Jetspeed Apache Jackrabbit  Apache Mina  Apache Qpid  Apache Sling  Apache Tapestry  Apache Wicket Aperture Apogee  Artifactory  Bitronix  DbUnit  Display tag  GMaven  Gradle GreenMail  GumTree  H2 Database  HA-JDBC  Hibernate  Igenko  Jabsorb Jetty v6  jLynx  JMesa  JODConverter JTrac  JWebUnit 2.x  LIFERAY  log4jdbc  Magnolia  MRCP4J  Mindquarry  Mugshot  Mule  Novocode  NetCDF  OpenRDF  Penrose  Proximity  PZFileReader  QuickFIX/J  SMSJ  Spring-OSGi  StreamBase  TimeFinder  WTFIGO  YASL  Xooctory
SLF4J (Simple Logging Facade for Java)
2009-11-24 16:21:42,203 INFO slf4j.MyProgram.printLog( MyProgram.java:11) - print info level log... 2009-11-24 16:21:42,234 DEBUG slf4j.MyProgram.printLog( MyProgram.java:12) - print debug level log... 2009-11-24 16:21:42,234 ERROR slf4j.MyProgram.printLog( MyProgram.java:13) - print error level log…
You don’t need to do any changes. 2009/11/24  下午  04:29:45 org.slf4j.impl.JCLLoggerAdapter info 資訊 : print info level log... 2009/11/24  下午  04:29:45 org.slf4j.impl.JCLLoggerAdapter error 嚴重的 : print error level log...

More Related Content

What's hot (20)

PDF
Intro to Reactive Programming
Stéphane Maldini
 
PDF
Understanding Java Garbage Collection
Azul Systems Inc.
 
PDF
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
HostedbyConfluent
 
PPTX
React hooks
Sadhna Rana
 
PDF
GraalVM Native and Spring Boot 3.0
MoritzHalbritter
 
PPTX
React Hooks
Joao Marins
 
PPTX
Where is my bottleneck? Performance troubleshooting in Flink
Flink Forward
 
PDF
React hooks Episode #1: An introduction.
ManojSatishKumar
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PPT
Spring Batch 2.0
Guido Schmutz
 
PPTX
Kubernetes #2 monitoring
Terry Cho
 
PPT
Java Server Faces (JSF) - Basics
BG Java EE Course
 
PPTX
React JS part 1
Diluka Wittahachchige
 
PDF
Java Performance Tuning
Ender Aydin Orak
 
PPTX
Better web apps with React and Redux
Ali Sa'o
 
KEY
Introduction to memcached
Jurriaan Persyn
 
PDF
Spring Security
Knoldus Inc.
 
PPTX
Introduction to react_js
MicroPyramid .
 
PPTX
JVM++: The Graal VM
Martin Toshev
 
PPTX
React.js - The Dawn of Virtual DOM
Jimit Shah
 
Intro to Reactive Programming
Stéphane Maldini
 
Understanding Java Garbage Collection
Azul Systems Inc.
 
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
HostedbyConfluent
 
React hooks
Sadhna Rana
 
GraalVM Native and Spring Boot 3.0
MoritzHalbritter
 
React Hooks
Joao Marins
 
Where is my bottleneck? Performance troubleshooting in Flink
Flink Forward
 
React hooks Episode #1: An introduction.
ManojSatishKumar
 
ReactJS presentation.pptx
DivyanshGupta922023
 
Spring Batch 2.0
Guido Schmutz
 
Kubernetes #2 monitoring
Terry Cho
 
Java Server Faces (JSF) - Basics
BG Java EE Course
 
React JS part 1
Diluka Wittahachchige
 
Java Performance Tuning
Ender Aydin Orak
 
Better web apps with React and Redux
Ali Sa'o
 
Introduction to memcached
Jurriaan Persyn
 
Spring Security
Knoldus Inc.
 
Introduction to react_js
MicroPyramid .
 
JVM++: The Graal VM
Martin Toshev
 
React.js - The Dawn of Virtual DOM
Jimit Shah
 

Similar to SLF4J (Simple Logging Facade for Java) (20)

PPTX
SLF4J Explained........
Sunitha Satyadas
 
PPTX
SLF4J+Logback
Guo Albert
 
PDF
Java Logging discussion Log4j,Slf4j
Rajiv Gupta
 
PPTX
Build, logging, and unit test tools
Allan Huang
 
PPT
slf4j-in-10-slides Jakarta Commons Logging
AlanNelson32
 
PPT
Logback
Anubhav Shukla
 
PPT
Log4e
Gagandeep Singh
 
PPTX
Logging and Exception
Azeem Mumtaz
 
PDF
Java logging
Jumping Bean
 
PDF
Log
Aircon Chen
 
PPTX
Logging with log4j v1.2
Kamal Mettananda
 
PPTX
Functional and non functional application logging
Sander De Vos
 
PPTX
Functional Application Logging : Code Examples Using Spring Boot and Logback
Mohammad Sabir Khan
 
PPTX
Log4j is a reliable, fast and flexible
Ramakrishna kapa
 
PDF
The new OSGi LogService 1.4 and integrating with SLF4J
bjhargrave
 
PDF
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
mfrancis
 
ODP
Logging with Logback in Scala
Knoldus Inc.
 
SLF4J Explained........
Sunitha Satyadas
 
SLF4J+Logback
Guo Albert
 
Java Logging discussion Log4j,Slf4j
Rajiv Gupta
 
Build, logging, and unit test tools
Allan Huang
 
slf4j-in-10-slides Jakarta Commons Logging
AlanNelson32
 
Logging and Exception
Azeem Mumtaz
 
Java logging
Jumping Bean
 
Logging with log4j v1.2
Kamal Mettananda
 
Functional and non functional application logging
Sander De Vos
 
Functional Application Logging : Code Examples Using Spring Boot and Logback
Mohammad Sabir Khan
 
Log4j is a reliable, fast and flexible
Ramakrishna kapa
 
The new OSGi LogService 1.4 and integrating with SLF4J
bjhargrave
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
mfrancis
 
Logging with Logback in Scala
Knoldus Inc.
 
Ad

More from Guo Albert (20)

PPTX
AWS IAM (Identity and Access Management) Policy Simulator
Guo Albert
 
PPTX
TOEIC 準備心得
Guo Albert
 
PDF
DBM專案環境建置
Guo Albert
 
PDF
JPA Optimistic Locking With @Version
Guo Albert
 
PDF
OCEJPA Study Notes
Guo Albert
 
PPTX
OCEJPA(1Z0-898) Preparation Tips
Guo Albert
 
PPTX
JPA lifecycle events practice
Guo Albert
 
PPTX
XDate - a modern java-script date library
Guo Albert
 
PDF
How to avoid check style errors
Guo Albert
 
PDF
NIG系統報表開發指南
Guo Albert
 
PDF
Ease Your Effort of Putting Data into History Table
Guo Albert
 
PDF
NIG 系統開發指引
Guo Albert
 
PDF
NIG系統開發文件閱讀步驟
Guo Albert
 
PDF
Form Bean Creation Process for NIG System
Guo Albert
 
PDF
A Short Intorduction to JasperReports
Guo Albert
 
PPTX
Apply Template Method Pattern in Report Implementation
Guo Albert
 
PPTX
Utilize Commons BeansUtils to do copy object
Guo Albert
 
PPTX
Apply my eclipse to do entity class generation
Guo Albert
 
PPTX
Nig project setup quickly tutorial
Guo Albert
 
PPTX
Spring JDBCTemplate
Guo Albert
 
AWS IAM (Identity and Access Management) Policy Simulator
Guo Albert
 
TOEIC 準備心得
Guo Albert
 
DBM專案環境建置
Guo Albert
 
JPA Optimistic Locking With @Version
Guo Albert
 
OCEJPA Study Notes
Guo Albert
 
OCEJPA(1Z0-898) Preparation Tips
Guo Albert
 
JPA lifecycle events practice
Guo Albert
 
XDate - a modern java-script date library
Guo Albert
 
How to avoid check style errors
Guo Albert
 
NIG系統報表開發指南
Guo Albert
 
Ease Your Effort of Putting Data into History Table
Guo Albert
 
NIG 系統開發指引
Guo Albert
 
NIG系統開發文件閱讀步驟
Guo Albert
 
Form Bean Creation Process for NIG System
Guo Albert
 
A Short Intorduction to JasperReports
Guo Albert
 
Apply Template Method Pattern in Report Implementation
Guo Albert
 
Utilize Commons BeansUtils to do copy object
Guo Albert
 
Apply my eclipse to do entity class generation
Guo Albert
 
Nig project setup quickly tutorial
Guo Albert
 
Spring JDBCTemplate
Guo Albert
 
Ad

Recently uploaded (20)

PPTX
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
PDF
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PDF
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PDF
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
PDF
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
PDF
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
PPTX
The birth and death of Stars - earth and life science
rizellemarieastrolo
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
The birth and death of Stars - earth and life science
rizellemarieastrolo
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 

SLF4J (Simple Logging Facade for Java)

  • 2. What is SLF4J? When should SLF4J be used? What are SLF4J's requirements? Parameterized logging Migration Who use SLF4J Demo
  • 3. The Simple Logging Facade for Java or (SLF4J) serves as a simple facade or abstraction for various logging frameworks, e.g. java.util.logging, log4j and logback, allowing the end user to plug in the desired logging framework at deployment time. http://www.slf4j.org/
  • 5. Suppose that your CRM application uses log4j for its logging. However, one of your important clients request that logging be performed through JDK 1.4 logging. If your application is riddled with thousands of direct log4j calls, migration to JDK 1.4 would be a relatively lengthy and error-prone process. Even worse, you would potentially need to maintain two versions of your CRM software. Had you been invoking SLF4J API instead of log4j, the migration could be completed in a matter of minutes by replacing one jar file with another .
  • 7. Binding Requirements slf4j-nop JDK 1.3 slf4j-simple JDK 1.3 slf4j-log4j12 JDK 1.3, plus any other library dependencies required by the log4j appenders in use slf4j-jdk14 JDK 1.4 or above logback-classic JDK 1.5 or above, plus any other library dependencies required by the logback appenders in use
  • 8. inefficient style logger.debug("Hello "+name); new style logger.debug("Hello {}", name);
  • 9. The SLF4J migrator is a small Java tool for migrating Java source files from the Jakarta Commons Logging (JCL) API to SLF4J. It can also migrate from the log4j API to SLF4J, or from java.util.logging API to SLF4J. For further information, please check: http://www.slf4j.org/migrator.html
  • 10. Apache Archiva Apache Directory Apache FTPServer Apache Geronimo Apache Graffito Apache Jetspeed Apache Jackrabbit Apache Mina Apache Qpid Apache Sling Apache Tapestry Apache Wicket Aperture Apogee Artifactory Bitronix DbUnit Display tag GMaven Gradle GreenMail GumTree H2 Database HA-JDBC Hibernate Igenko Jabsorb Jetty v6 jLynx JMesa JODConverter JTrac JWebUnit 2.x LIFERAY log4jdbc Magnolia MRCP4J Mindquarry Mugshot Mule Novocode NetCDF OpenRDF Penrose Proximity PZFileReader QuickFIX/J SMSJ Spring-OSGi StreamBase TimeFinder WTFIGO YASL Xooctory
  • 12. 2009-11-24 16:21:42,203 INFO slf4j.MyProgram.printLog( MyProgram.java:11) - print info level log... 2009-11-24 16:21:42,234 DEBUG slf4j.MyProgram.printLog( MyProgram.java:12) - print debug level log... 2009-11-24 16:21:42,234 ERROR slf4j.MyProgram.printLog( MyProgram.java:13) - print error level log…
  • 13. You don’t need to do any changes. 2009/11/24 下午 04:29:45 org.slf4j.impl.JCLLoggerAdapter info 資訊 : print info level log... 2009/11/24 下午 04:29:45 org.slf4j.impl.JCLLoggerAdapter error 嚴重的 : print error level log...