Logback is built on top of three main classes: Logger,appender and layout. These three components work together to enable developers to record messages by message type and level, and to control the output format and output destination of messages during the program's run time.
The logger class is part of the Logback-classic module, and the Appender and layout interfaces come from Logback-core. As a multipurpose module, Logback-core does not contain any logger.
1. Logger context
In Logback-classic, each logger is linked to a loggercontext,loggercontext responsible for manufacturing logger, and is responsible for arranging the logger in a tree structure. The logger is a named entity. Their names are case sensitive and follow the hierarchical naming conventions: If the name of the logger is prefixed with the name of another logger, then the former is called the ancestor of the latter. If there is no other ancestor between logger and its descendants logger, then the former is called the father of the child logger. The root logger is at the top of the logger level, and what is special about it is that it is the common ancestor of each level. Like all other logger, the root logger can be obtained by its name, as follows:
Logger Rootlogger = Loggerfactory.getlogger (Org.slf4j.Logger.ROOT_LOGGER_NAME);
All other logger are also obtained by GetLogger the static method of the Org.slf4j.LoggerFactory class. The GetLogger method is called a parameter with the logger name.
2. Level of validity level inheritance
Logger can be assigned a level. The levels are: Trace,debug,info,warn and error, defined in the Ch.qos.logback.classic.Level class. Note that in Logback, the level class is final and cannot be inherited, and the marker object provides a more flexible approach.
If the logger is not assigned a level, it inherits from the nearest ancestor with the assigned level. More formally: The effective level of logger L is equal to the first non-null level of its hierarchy, in order from L onwards up to root logger. To ensure that all logger can eventually inherit a level, the root logger always has a level, by default, this level is debug.
Not yet finished ... .....-.......................... ....... ..... .................. .........
The Logger,appender and layout of Logback