- SLF4J - Discussion
- SLF4J - Useful Resources
- SLF4J - Quick Guide
- SLF4J - Profiling
- SLF4J - Migrator
- SLF4J - Parameterized logging
- SLF4J - Error Messages
- SLF4J - Hello world
- SLF4J - Referenced API
- SLF4J - Environment Setup
- SLF4J Vs Log4j
- SLF4J - Logging Frameworks
- SLF4J - Overview
- SLF4J - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SLF4J - Referenced API
In this chapter, we will discuss the classes and methods that we will be using in the subsequent chapters of this tutorial.
Logger Interface
The logger interface of the org.slf4j package is the entry point of the SLF4J API. The following psts down the important methods of this interface.
Sr.No. | Methods and Description |
---|---|
1 | void debug(String msg) This method logs a message at the DEBUG level. |
2 | void error(String msg) This method logs a message at the ERROR level. |
3 | void info(String msg) This method logs a message at the INFO level. |
4 | void trace(String msg) This method logs a message at the TRACE level. |
5 | void warn(String msg) This method logs a message at the WARN level. |
LoggerFactory Class
The LoggerFactory class of the org.slf4j package is a utipty class, which is used to generate loggers for various logging APIs such as log4j, JUL, NOP and simple logger.
Sr.No. | Method and Description |
---|---|
1 | Logger getLogger(String name) This method accepts a string value representing a name and returns a Logger object with the specified name. |
Profiler Class
This class belongs to the package org.slf4j this is used for profipng purpose and it is known as poor man’s profiler. Using this, the programmer can find out the time taken to carry out prolonged tasks.
Following are the important methods of this class.
Sr.No. | Methods and Description |
---|---|
1 | void start(String name) This method will start a new child stop watch (named) and, stops the earper child stopwatches (or, time instruments). |
2 | TimeInstrument stop() This method will stop the recent child stopwatch and the global stopwatch and return the current Time Instrument. |
3 | void setLogger(Logger logger) This method accepts a Logger object and associates the specified logger to the current Profiler. |
4 | void log() Logs the contents of the current time instrument that is associated with a logger. |
5 | void print() Prints the contents of the current time instrument. |