当前位置:网站首页>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>
边栏推荐
- 企业级日志分析系统ELK
- Notification uses full resolution
- MySQL中, 如何查询某一天, 某一月, 某一年的数据
- Leetcode-136- number that appears only once (solve with XOR)
- 2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
- Common training data set formats for target tracking
- Unity drawing plug-in = = [support the update of the original atlas]
- The inevitable trend of the intelligent development of ankerui power grid is that microcomputer protection devices are used in power systems
- Bidding announcement: Fujian Rural Credit Union database audit system procurement project (re bidding)
- Sysom case analysis: where is the missing memory| Dragon lizard Technology
猜你喜欢

Plate - forme de surveillance par étapes zabbix

torch.numel作用

AE learning 01: AE complete project summary

Power of leetcode-231-2

SPI master RX time out interrupt

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"?

Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()
![Unity drawing plug-in = = [support the update of the original atlas]](/img/b0/92114ffb1f168a1f27125db46c6797.jpg)
Unity drawing plug-in = = [support the update of the original atlas]

What are compiled languages and interpreted languages?

Odoo集成Plausible埋码监控平台
随机推荐
一个普通人除了去工厂上班赚钱,还能干什么工作?
laravel中将session由文件保存改为数据库保存
torch.numel作用
How does geojson data merge the boundaries of regions?
Tragedy caused by deleting the console statement
laravel post提交数据时显示异常
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
模仿企业微信会议室选择
There are many ways to realize the pause function in JS
Laravel5.1 Routing - routing packets
Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
JS modularization
logback.xml配置不同级别日志,设置彩色输出
Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
three.js打造酷炫下雪效果
Three. JS introductory learning notes 19: how to import FBX static model
HAVE FUN | “飞船计划”活动最新进展
JS 模块化
Dotween -- ease function
[vulnhub range] thales:1