7dev70
7dev70

Reputation: 31

Prevent to log both to catalina.out and log4j logfiles

I know, that there are many similar questions and answers about logging to catalina.out and logging to log4j logfiles, but so far i haven't found a correct answer to my problem and i don't want to turn off logging to catalina.out

My motivation is to have a split here between logmessages related to my application and logmessages related to tomcaterrors.

I want to make sure, when something is logged into log4j's own logfiles, that it is not doubly logged into catalina.out, but when it is not handled by log4j, that it is still written into catalina.out.

But how?

Upvotes: 0

Views: 2421

Answers (1)

xl0e
xl0e

Reputation: 371

try this configuration

# console out only for org.apache.catalina
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.logger.org.apache.catalina=debug, A1
log4j.additivity.org.apache.catalina=false


# common output
log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.file=console.log
log4j.appender.A2.layout=org.apache.log4j.PatternLayout

log4j.rootLogger=info, A2

Upvotes: 1

Related Questions