Logback is intended as a successor to the popular log4j project, picking up where log4j leaves off.

logback is divided into three modules, logback-core, logback-classic and logback-access.

logback三大模块的简介:

log4j.properties to logback.xml Translator:http://logback.qos.ch/translator/

logback.xml to logback.groovy translator:http://logback.qos.ch/translator/asGroovy.html

官方教程(英文版):http://logback.qos.ch/manual/index.html (over 150 pages and dozens of concrete examples)推荐!!!慢慢读,慢即是快。

依赖关系:

官方示例:

package chapters.introduction;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;public class HelloWorld2 {public static void main(String[] args) {Logger logger = LoggerFactory.getLogger("chapters.introduction.HelloWorld2");logger.debug("Hello world.");// print internal stateLoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();StatusPrinter.print(lc);}
}

可以不手动配置Logback(即无相关配置文件):

By virtue of logback's default configuration policy, when no default configuration file is found, logback will add a ConsoleAppender to the root logger.

Appender(输出目的地):an output destination is called an appender. Currently, appenders exist for the console, files, remote socket servers, to MySQL, PostgreSQL, Oracle and other databases, JMS, and remote UNIX Syslog daemons.

More than one appender can be attached to a logger.

Logback中的Level:

示例:

import ch.qos.logback.classic.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
....// get a logger instance named "com.foo". Let us further assume that the
// logger is of type  ch.qos.logback.classic.Logger so that we can
// set its level
ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("com.foo");
//set its Level to INFO. The setLevel() method requires a logback logger
logger.setLevel(Level. INFO);Logger barlogger = LoggerFactory.getLogger("com.foo.Bar");// This request is enabled, because WARN >= INFO
logger.warn("Low fuel level.");// This request is disabled, because DEBUG < INFO.
logger.debug("Starting search for nearest gas station.");// The logger instance barlogger, named "com.foo.Bar",
// will inherit its level from the logger named
// "com.foo" Thus, the following request is enabled
// because INFO >= INFO.
barlogger.info("Located nearest gas station.");// This request is disabled, because DEBUG < INFO.
barlogger.debug("Exiting gas station search");

同名则同物:

继承无序:

In fundamental contradiction to biological parenthood, where parents always precede their children, logback loggers can be created and configured in any order. In particular, a "parent" logger will find and link to its descendants even if it is instantiated after them.

Logger的命名策略:

This can be accomplished by instantiating a logger in each class, with the logger name equal to the fully qualified name of the class. This is a useful and straightforward method of defining loggers. As the log output bears the name of the generating logger, this naming strategy makes it easy to identify the origin of a log message. However, this is only one possible, albeit common, strategy for naming loggers. Logback does not restrict the possible set of loggers. As a developer, you are free to name loggers as you wish.

Nevertheless, naming loggers after the class where they are located seems to be the best general strategy known so far.

Appender的附加规则:

示例:

各个level的关系:

配置文件的结构:

极简入门:https://www.liaoxuefeng.com/wiki/1252599548343744/1264739155914176

logback.xml详解:https://www.jianshu.com/p/75f9d11ae011

#Logback入门 @FDDLC相关推荐

  1. LogBack 入门实践

    一.简介 前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. LogBack是一个日志框架,它是Log4j作者Ceki的又一个日志组件. LogBack ...

  2. Logback 专题

    logback-spring.xml <?xml version="1.0" encoding="UTF-8"?> <configuratio ...

  3. 005_logback介绍

    1. 什么是logback 1.1. Logback由log4j的创始人设计的又一个开源日志组件.以十多年设计工业级记录系统的经验为基础, 所创建的logback比现有任何记录系统更快.占用资源更少. ...

  4. 品达通用_9. pd-tools-log

    品达通用_9. pd-tools-log 文章目录 品达通用_9. pd-tools-log 9. pd-tools-log 9.1 logback 9.1.1 logback介绍 9.1.2 log ...

  5. 六、品达通用权限系统__pd-tools-log

    一.pd-tools-log pd-tools-log模块定位为日子模块,本质也是一个starter.提供的日志功能主要有两个方面: 通过logback框架可以在控制台或者日志文件记录日志信息 拦截用 ...

  6. Java通用权限系统视频(2021年高含金量版)

    来源: 来自网络,如侵权请告知博主删除????. 仅学习使用,请勿用于其他- 大家好,我是肉哥,最近有小伙伴联系我需要通用权限系统相关资源,分享给大家! 目录 01-课程介绍.mp4: U, ?9 r ...

  7. Java通用权限管理系统第一天

    品达通用权限系统 1. 项目概述 1.1 项目介绍 对于企业中的项目绝大多数都需要进行用户权限管理.认证.鉴权.加密.解密.XSS防跨站攻击等.这些功能整体实现思路基本一致,但是大部分项目都需要实现一 ...

  8. linux安装软件imagemagick,linux下的ImageMagick安装方法

    linux下的ImageMagick安装方法 由于没有图形化界面的支持,在Linux(CentOS 6.4 x64)上的配置相对Windows XP还是麻烦了一点. 1.下载ImageMagick和J ...

  9. Java - 日志(进阶篇)

    一.日志门面 当我们的系统变的更加复杂的时候,我们的日志就容易发生混乱.随着系统开发的进行,可能会更新不同的日志框架,造成当前系统中存在不同的日志依赖,让我们难以统一的管理和控制.就算我们强制要求所有 ...

  10. 多种java 日志框架【超详细图文】

    一.目标 日志的作用和目的 日志的框架 JUL的使用 LOG4J的使用 JCL的使用 二.日志的概念 2.1 日志文件 日志文件是用于记录系统操作事件的文件集合,可分为事件日志和消息日志.具有处理历史 ...

最新文章

  1. python操作gif
  2. menuItem无法响应点击事件
  3. 32时间片轮转_系统时间
  4. 数据库中的实体、元组、字段、属性、码、分量、依赖关系、完全部份传递依赖、范式等你了解吗?【笔记自用】
  5. linux同步硬件和系统时钟,liunx系统下时钟不同步会出现问题 怎么同步Linux 的系统时钟和硬件时钟?...
  6. 记一次 .NET 某上市工业智造 CPU+内存+挂死 三高分析
  7. 常用的基本Windows数据类型
  8. 后台返回数据打印是[object object]的,报错:SyntaxError: JSON.parse: expected property name or ‘}‘ at line 1 column
  9. eq值 推荐算法_C++实现十种排序算法
  10. 音视频开发(15)---IPC+NVR+路由器+ffmpeg+nginx实现网页/Android/IOS的HLS直播
  11. 数据处理——数据编码
  12. linux下docker部署nginx
  13. 在EditPlus中配置java快捷键
  14. 第二章 Jsp基本语法
  15. 大话数据结构PDF原文内容分享
  16. 【ffplay】视频的宽高比详解 -PAR、DAR 和 SAR
  17. python 倒计时手机app打卡_摆脱拖延症,这些APP让你的时间更高效!
  18. oracle删sequen,Oracle中如何创建使用SEQUENCES
  19. VueJs笔记01-视频小码哥
  20. cmake和make的简单理解

热门文章

  1. 百度接口API的使用
  2. 开学季将至 华硕重炮手主板让你学习娱乐两不误
  3. 正交编码 正交编码器 增量式编码器
  4. 网络语言2019流行语C位解,最新骂人网络语言 2019网络骂人流行语大全
  5. 华硕主板无盘启动bios设置_华硕主板怎么进入bios?华硕主板进入bios设置u盘启动方法...
  6. java基本类型的小把戏
  7. 访问图片出现403的解决办法
  8. 计算机应用新媒体是什么,新媒体概念,什么是新媒体
  9. Win10 Cortana 搜索框字体颜色
  10. 一个树莓派集群 (VAX)