0

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?

7dev70
  • 31
  • 5

1 Answers1

1

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
xl0e
  • 361
  • 3
  • 9
  • That looks promising and i am still testing. Could you point me to the location where this configuration switch is described? – 7dev70 Mar 16 '17 at 15:50
  • https://logging.apache.org/log4j/2.x/manual/configuration.html#Additivity – xl0e Mar 17 '17 at 07:41