Answer the question
In order to leave comments, you need to log in
How to set up log4j for a multi-threaded environment?
There is a service that receives phone calls, all data is logged to files using log4j.
There are a lot of sessions and they overlap each other. I tried to add a SessionID through MDC in order to at least somehow deal with the logs, but since the MDC is a static class, the data was overwritten and mess again. How to be?
one of the templates is:
# ERROR
#log4j.appender.ERROR=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ERROR=org.apache.log4j.RollingFileAppender
log4j.appender.ERROR.File=${folder_real}error.log
#log4j.appender.ERROR.DatePattern='.'yyyy-MM-dd
log4j.appender.ERROR.MaxFileSize=4096MB
log4j.appender.ERROR.MaxBackupIndex=1
log4j.appender.ERROR.layout=org.apache.log4j.PatternLayout
log4j.appender.ERROR.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %-5p - %X{SCESession}:%C{1}:%L %m%n
log4j.appender.ERROR.Encoding=UTF-8
Answer the question
In order to leave comments, you need to log in
since the MDC static class data was overwritten and mess again
grep %session% file.log
. If the system generates a lot of logs, then systems like Splunk are used to simplify searching through many files and organize all the logs into a single database.log4j.appender.asyncLog=com.log.AsyncAppenderHelper
will it help?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question