log4j.rootLogger=DEBUG,stdout log4j.logger.notRootLogger=DEBUG,somewhereelse
附加信号stdout和athereelse都配置正确,stdout写入控制台和某个文件的写入.
在我的每个类的代码中,我设置:
static Logger log = Logger.getLogger("notRootLogger);
^当我不想要的东西去控制台.
-要么-
static Logger log = Logger.getRootLogger();
当我做的
在log4.properties中必须做什么才能阻止写入toRootLogger的东西以stdout结尾?是否有某种继承,无论根记录器写入哪里,需要关闭某种方式?
我不想单独为每个单独的类配置一个记录器,我只想登录到控制台.
解决方法
Each enabled logging request for a
given logger will be forwarded to all
the appenders in that logger as well
as the appenders higher in the
hierarchy. In other words,appenders
are inherited additively from the
logger hierarchy. For example,if a
console appender is added to the root
logger,then all enabled logging
requests will at least print on the
console. If in addition a file
appender is added to a logger,say C,
then enabled logging requests for C
and C’s children will print on a file
and on the console. It is possible to
override this default behavior so that
appender accumulation is no longer
additive by setting the additivity
flag to false.
尝试这个:
log4j.rootLogger=DEBUG,stdout log4j.logger.notRootLogger=DEBUG,somewhereelse log4j.additivity.notRootLogger=false