阿里的开源Java诊断工具Arthas可以在线调整log等级
- 查找当前类的classloader hashcode
1 | sc -d com.example.demo.arthas.user.UserController | grep classLoaderHash |
- 用OGNL获取logger
1 | ognl -c 1be6f5c3 '@com.example.demo.arthas.user.UserController@logger' |
- 单独设置UserController的logger level
1 | ognl -c 1be6f5c3 '@com.example.demo.arthas.user.UserController@logger.setLevel(@ch.qos.logback.classic.Level@DEBUG)' |
- 全局设置logger level
1 | ognl -c 1be6f5c3 '@org.slf4j.LoggerFactory@getLogger("root").setLevel(@ch.qos.logback.classic.Level@DEBUG)' |