Spring Boot中实现logback多环境日志配置
在Spring Boot中,可以在logback.xml中的springProfile标签中定义多个环境
logback.xml:
<springProfile name="production">
<root level="DEBUG">
<appender-ref ref="STDOUT"/> </root>
</springProfile>
<springProfile name="dev">
<root level="DEBUG">
<appender-ref ref="CONSOLE"/> </root>
</springProfile>
现在想要将logback.xml文件拆分为logback-production.xml,logback-dev.xml两个文件(logback-{profile}.xml),而不是定义在同一个文件中。然后应用会根据profile确定使用哪个配置文件。
application.properties里面配置:
logging.config: classpath:logback-${spring.profiles.active}.xml
启动时指定:
java -jar xxx.jar --spring.profiles.active=dev
也可以在application.properties指定:
spring.profiles.active=dev
参考:
https://docs.spring.io/spring-boot/docs/1.5.7.RELEASE/reference/htmlsingle/#boot-features-custom-log-configuration(官方配置参考,一切答案都在这里)
http://blog.csdn.net/m0_37895333/article/details/72457007
http://www.cnblogs.com/wuyechun/p/6800956.html
http://blog.csdn.net/vitech/article/details/53812137
Spring Boot中实现logback多环境日志配置的更多相关文章
- Spring Boot中使用logback日志框架
说明:Spring Boot在最新的版本中默认使用了logback框架.一般来说使用时只需在classpath下创建logback.xml即可,而官方推荐使用logback-spring.xml替代, ...
- Spring Boot中使用AOP记录请求日志
这周看别人写的springboot后端代码中有使用AOP记录请求日志,以前没接触过,因此学习下. 一.AOP简介 AOP为Aspect Oriented Programming的缩写,意为:面向切面编 ...
- 徒手撸一个 Spring Boot 中的 Starter ,解密自动化配置黑魔法!
我们使用 Spring Boot,基本上都是沉醉在它 Stater 的方便之中.Starter 为我们带来了众多的自动化配置,有了这些自动化配置,我们可以不费吹灰之力就能搭建一个生产级开发环境,有的小 ...
- 利用 Spring Boot 中的 @ConfigurationProperties,优雅绑定配置参数
使用 @Value("${property}") 注释注入配置属性有时会很麻烦,尤其是当你使用多个属性或你的数据是分层的时候. Spring Boot 引入了一个可替换的方案 -- ...
- spring boot 中 Mybatis plus 多数据源的配置方法
最近在学习spring boot,发现在jar包依赖方面做很少的工作量就可以了,对于数据库操作,我用的比较多的是mybatis plus,在中央仓库已经有mybatis-plus的插件了,对于单数据源 ...
- Spring boot结合Maven实现不同环境的配置
配置文件层次: pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http ...
- Spring Boot(5) 集成Hibernate 日志配置
https://blog.csdn.net/ZNG_XP/article/details/78131809 https://blog.csdn.net/u011998835/article/detai ...
- Spring Boot 中的静态资源到底要放在哪里?
当我们使用 SpringMVC 框架时,静态资源会被拦截,需要添加额外配置,之前老有小伙伴在微信上问松哥Spring Boot 中的静态资源加载问题:"松哥,我的HTML页面好像没有样式?& ...
- spring boot中log4j冲突问题和解决办法
Spring Boot中自带了log4j日志管理.写法应该是: private static final Logger logger = Logger.getLogger(XXX.class); 而不 ...
随机推荐
- Smart Contracts
A smart contract is a computer code running on top of a blockchain containing a set of rules under w ...
- 【转载】用Python实现端口映射功能(A/B/C内外网)
转载地址 :http://hutaow.com/blog/2014/09/08/write-tcp-mapping-program-with-python/ 有A,B,C三台计算机,A,B互通,B,C ...
- 解决CSDN阅读全部需要登录的问题
现在CSDN网站每次点击“阅读全部”的时候,必须要登录才能展开,很不方便.解决方法如下:点击F12打开开发者工具,点击Console,将下面两行代码粘贴进去即可: $("div.articl ...
- Linux test命令
test命令 长格式的例子: test "$A" == "$B" && echo "Strings are equal" t ...
- 条款14:在资源管理类中心copying行为(Think carefully about copying behavior in resource-manage classes)
NOTE: 1.复制RAII 对象必须一并赋值它所管理的资源,所以资源的copying行为决定RAII对象的copying行为. 2.普遍而常见的RAII class copying 行为是: 抑制c ...
- maven添加本地jar包到本地仓库
1 进入jar包所在文件夹,进入cmd命令 2 执行命令 mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -Dartif ...
- [第一波模拟\day3\T3]{益智游戏}(game.cpp)
[问题描述] 小P和小R在玩一款益智游戏.游戏在一个正权有向图上进行. 小P控制的角色要从A点走最短路到B点,小R控制的角色要从C点走最短路到D点. 一个玩家每回合可以有两种选择,移动到一个相邻节点或 ...
- 【Codeforces 25C】Roads in Berland
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 用floyd思想. 求出来这条新加的边影响到的点对即可. 然后尝试更新点对之间的最短路就好. 更新之后把差值从答案里面减掉. [代码] #in ...
- luogu1447 [NOI2010]能量采集
考虑暴力,答案显然是 \(\sum_{i=1}^n\sum_{j=1}^m(2(\gcd(i,j)-1)+1)=\sum_{i=1}^n\sum_{j=1}^m(2\gcd(i,j)-1)\). 考虑 ...
- Extjs中获取grid数据
(1)grid.getStore().getRange(0,store.getCount()); //得到grid所有的行 (2)grid.getSelectionModel().getSelecti ...