如何从log4j附加程序中排除程序包 [英] How to exclude a package from a log4j appender

查看:77
本文介绍了如何从log4j附加程序中排除程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有配置文件(log4j.properties),请参阅下面的软件包,并在末尾提问.

I have configuration file (log4j.properties), see the packages below and and question at the end.

  com.bitguiders.package1
  com.bitguiders.package2
  com.bitguiders.package3
  com.bitguiders.package4
  com.bitguiders.package5
  com.bitguiders.package6
  com.bitguiders.package7

我想记录除此软件包以外的所有内容

I want to log everything except this package

 com.bitguiders.package2 

我该怎么做? (假设我有50个包裹,但我仍然想排除一两个包裹)

How can i do that ? (Assume i have 50 packages and still i wanted to exclude one or two pacakges)

推荐答案

您可以设置日志 OFF (对于某些软件包):

You can set the log Level to OFF for some packages:

# set the log level 
log4j.logger.com.bitguiders=INFO
log4j.logger.com.bitguiders.package2=OFF
log4j.logger.com.bitguiders.packageX=OFF

您可以使用 ,例如:

log4j.rootLogger=INFO, FILE

log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=/somepath/somefile.log
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=[%p] %d %c %M - %m%n

为了将日志从不同的包发送到不同的文件,

In order to send log from different packages to different files:

log4j.rootLogger=WARN, FILEA, FILEB
log4j.logger.com.bitguiders.package1=INFO, FILEA
log4j.logger.com.bitguiders.package2=INFO, FILEA
log4j.logger.com.bitguiders.package3=INFO, FILEB

在这里回答:使用Log4J 1. *,如何将两个程序包写入两个单独的文件?

这篇关于如何从log4j附加程序中排除程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆