当前位置:网站首页>logback. XML configure logs of different levels and set color output
logback. XML configure logs of different levels and set color output
2022-07-07 16:24:00 【kill-java】
yml perhaps properties The configuration file
logging.config=classpath:logback.xml
resources New under the directory logback.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!-- Root tag -->
<configuration>
<!-- Set a variable ,name Variable name ,value Value , have access to ${
Variable name } Way to use -->
<property name="DIR" value="log"/>
<property name="LOG_HOME" value="/F:/project/logs"/>
<property name="NAME" value="log"/>
<property name="MDC_LOG_PATTERN"
value="%red(%d{yyyy-MM-dd'T'HH:mm:ss.SSS}) %green(%p filesystem %t) %blue(%logger{50}) %yellow([line:%L %msg]%n)"></property>
<!-- Run loggers , Date roll record -->
<appender name="info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- The path and filename of the log file being logged -->
<file>${
LOG_HOME}/${
NAME}/info/${
NAME}.log</file>
<!-- Rolling policy for loggers , By date , Record by size -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${
LOG_HOME}/${
NAME}/info/${
NAME}-%d{
yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- In addition to logging , It is also configured that the log file cannot exceed 50M, If more than 50M, Log files will be indexed 0 Start , Name the log file , for example bizlog-biz-20181219.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
<!-- Storage time 3 God -->
<!--<MaxHistory>3</MaxHistory>-->
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- Add method to record log -->
<append>true</append>
<!-- Format of log file -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{
yyyy/MM/dd' 'HH:mm:ss.SSS} %X{
req.requestId}[line:%L %msg] %n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- This log file only records info Grade -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- The path and filename of the log file being logged -->
<file>${
LOG_HOME}/${
NAME}/error/${
NAME}.log</file>
<!-- Rolling policy for loggers , By date , Record by size -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${
LOG_HOME}/${
NAME}/error/${
NAME}-%d{
yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- In addition to logging , It is also configured that the log file cannot exceed 50M, If more than 50M, Log files will be indexed 0 Start , Name the log file , for example bizlog-biz-20181219.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
<!-- Storage time 3 God -->
<!--<MaxHistory>3</MaxHistory>-->
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- Add method to record log -->
<append>true</append>
<!-- Format of log file -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{
yyyy/MM/dd' 'HH:mm:ss.SSS} %X{
req.requestId}[line:%L %msg] %n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- This log file only records info Grade -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>error</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!--ConsoleAppender Is printed to the console -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!--encoder Default configuration is PatternLayoutEncoder-->
<encoder>
<pattern>${
MDC_LOG_PATTERN}</pattern>
<charset>utf-8</charset>
</encoder>
<!-- This log appender It's for development , Configure only the lowest level , The console output log level is greater than or equal to this level of log information -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>all</level>
</filter>
</appender>
<!-- root loger. only one level attribute , It should have been named "root".-->
<root level="info">
<appender-ref ref="info"/>
<appender-ref ref="STDOUT"/>
<appender-ref ref="error"/>
</root>
</configuration>
边栏推荐
- Performance measure of classification model
- 分类模型评价标准(performance measure)
- What are compiled languages and interpreted languages?
- leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)
- 目标跟踪常见训练数据集格式
- Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"
- laravel 是怎么做到运行 composer dump-autoload 不清空 classmap 映射关系的呢?
- 模仿企业微信会议室选择
- The unity vector rotates at a point
- leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
猜你喜欢

喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配

Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"

Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models

Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?

How does geojson data merge the boundaries of regions?

Vs tool word highlight with margin

Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()

预测——灰色预测

SPI master rx time out中断

Xcode Revoke certificate
随机推荐
ThinkPHP URL 路由简介
模仿企业微信会议室选择
Balanced binary tree (AVL)
The differences between exit, exit (0), exit (1), exit ('0 '), exit ('1'), die and return in PHP
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
Iptables only allows the specified IP address to access the specified port
torch. Numel action
MySQL数据库基本操作-DQL-基本查询
AE learning 02: timeline
Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?
thinkphp3.2.3中设置路由,优化url
Power of leetcode-231-2
Sysom case analysis: where is the missing memory| Dragon lizard Technology
Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?
Step by step monitoring platform ZABBIX
121. 买卖股票的最佳时机
JS 模块化
markdown公式编辑教程
Logback日志框架第三方jar包 免费获取
Markdown formula editing tutorial