SpringBoot - 日志集成 Log4j2
2017-01-18 12:06
851 查看
Log4j2
引入log4j2 依赖,spring-boot-starter-log4j2排除Springboot logging
针对特别其他的log日志兼容比如logback引入 log4j-1.2-api
排除logback
application.yml 中设置日志配置文件
build.gradle
dependencies { compile('org.springframework.boot:spring-boot-starter-log4j2') compile('org.apache.logging.log4j:log4j-1.2-api:'+ log4jAPIVersion) } configurations { all*.exclude module: 'spring-boot-starter-logging' all*.exclude module: 'logback-classic' all*.exclude module: 'log4j-over-slf4j' }
application.yml
logging: config: classpath:log4j2-spring.xml
创建 log4j2-spring.xml
<?xml version="1.0" encoding="utf-8"?> <configuration> <properties> <property name="PATTERN">%d{yyyy-MM-dd HH:mm:ss.SSS} |-%-5level [%thread] %c [%L] -| %msg%n</property> </properties> <appenders> <Console name="CONSOLE" target="system_out"> <PatternLayout pattern="${PATTERN}" /> </Console> </appenders> <loggers> <root level="debug"> <appenderref ref="CONSOLE" /> </root> </loggers> </configuration>
更多集成参考springboot github
代码
代码请移步 Github参考地址
如有疑问请加公众号(K171),如果觉得对您有帮助请 github start相关文章推荐
- Spring Boot 集成log4j2日志
- Spring Boot系列教程六:日志输出配置log4j2
- Spring Boot系列教程六:日志输出配置log4j2
- Springboot+logback集成ELK处理日志实例
- SpringBoot系列十一:SpringBoot整合Restful架构(使用 RestTemplate 模版实现 Rest 服务调用、Swagger 集成、动态修改日志级别)
- spring boot 学习(六)spring boot 各版本中使用 log4j2 记录日志
- SpringBoot Log4j2日志分级输出
- 【SpringBoot探索二】SpringBoot项目集成日志记录功能
- 使用spring-boot集成dubbo的日志
- Spring Boot 集成 log4j2
- Spring Boot 集成日志 logging sl4j
- SpringBoot 配置log4j2日志输出
- (六)Spring Boot之日志配置-logback和log4j2
- 从零开始学spring-boot(3)-集成logback日志
- 使用Log4J2.properties作为Spring Boot的日志工具
- 8.7 Spring Boot集成日志
- 13.7 SpringBoot集成日志系统logback的几个问题
- 第六章:Spring Boot log4j2日志引用(三)
- springboot-05集成日志logback讲解
- Spring 5.0集成log4j2日志管理的示例代码