Java log4j.additivity取消日志继承为何无效
Posted dum
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java log4j.additivity取消日志继承为何无效相关的知识,希望对你有一定的参考价值。
log4j1日志继承说明: 略.
简短说明问题原因: "log4j.additivity"后边跟的包路径必须和另一项配置"log4j.logger"后边跟的包路径能对上, log4j不会分析你的项目的包结构.
例如:考虑取消com.game.gmActivation.logger包下的几个logger的继承关系, 只输出到指定路径的日志里, 错误的配置是只写一条父级包路径配置:
# 以下包路径的日志取消继承
log4j.additivity.com.game.gmActivation.logger=false
##行为日志定向配置
log4j.logger.com.game.gmActivation.logger.gameCurrency=INFO,gameCurrencyLog
log4j.logger.com.game.gmActivation.logger.onlineRoleNum=INFO,onlineRoleNumLog
log4j.logger.com.game.gmActivation.logger.itemBuy=INFO,itemBuyLog
log4j.logger.com.game.gmActivation.logger.zuanshiUse=INFO,zuanshiUseLog
log4j.logger.com.game.gmActivation.logger.gameSysActive=INFO,gameSysActiveLog
正确的配置为列举全部配置, 一一对应.
# 以下包路径的日志取消继承
log4j.additivity.com.game.gmActivation.logger.gameCurrency=false
log4j.additivity.com.game.gmActivation.logger.onlineRoleNum=false
log4j.additivity.com.game.gmActivation.logger.itemBuy=false
log4j.additivity.com.game.gmActivation.logger.zuanshiUse=false
log4j.additivity.com.game.gmActivation.logger.gameSysActive=false
##行为日志定向配置
log4j.logger.com.game.gmActivation.logger.gameCurrency=INFO,gameCurrencyLog
log4j.logger.com.game.gmActivation.logger.onlineRoleNum=INFO,onlineRoleNumLog
log4j.logger.com.game.gmActivation.logger.itemBuy=INFO,itemBuyLog
log4j.logger.com.game.gmActivation.logger.zuanshiUse=INFO,zuanshiUseLog
log4j.logger.com.game.gmActivation.logger.gameSysActive=INFO,gameSysActiveLog
欢迎留言指正.
以上是关于Java log4j.additivity取消日志继承为何无效的主要内容,如果未能解决你的问题,请参考以下文章