Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a log4j properties something like below. Everything that is logged in TextProcessor.log is something above WARN level. I don't understand the threshold that is set here to debug. Can someone explain what the threshold does?

log4j.logger.TextProcessor=warn,TextProcessor 

log4j.appender.TextProcessor=org.apache.log4j.RollingFileAppender
log4j.appender.TextProcessor.File=C:/project/logs/TextProcessor.log
log4j.appender.TextProcessor.MaxFileSize=10MB
log4j.appender.TextProcessor.MaxBackupIndex=10
log4j.appender.TextProcessor.Threshold=debug
log4j.appender.TextProcessor.layout=org.apache.log4j.PatternLayout
log4j.appender.TextProcessor.layout.ConversionPattern=[%d] [%5p] (%F:%L) - %m%n
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
241 views
Welcome To Ask or Share your Answers For Others

1 Answer

You have two things here : a logger, and an appender. Unfortunately, you chose the same name for both, which doesn't make it very clear.

The logger's minimum level is set to warn, which means everything you log with this logger which doesn't have at least the warn level will be ignored.

Once a message is accepted by the logger, it's sent to one or several appenders (to a file, to the console, to a mail server, etc.). Each of these appenders may define a threshold. You could for example limit the messages in the console to errors, but accept warn messages in the log file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...