Java – extend log4j error email with more information

The web application I'm using provides more logs for users' data integrity problems I would like more information, such as:

>Servername > client IP > browser information

Is there any way for log4j to record the above parameters? In other words, I want to add these parameters with other parameters So does log4j provide some methods for this?

I have log4j The properties are:

log4j.appender.Stdout=org.apache.log4j.ConsoleAppender
log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.Stdout.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n

log4j.appender.Stdout=org.apache.log4j.ConsoleAppender
log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.Stdout.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n

log4j.rootLogger=INFO,Stdout

log4j.logger.org.apache.wicket=INFO
log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO
log4j.logger.org.apache.wicket.version=INFO
log4j.logger.org.apache.wicket.RequestCycle=INFO

I have a logutil Java class, in which I record the available information

Editor: what's my problem more clearly

Where can I find these parameters and how can I add them to an existing logger?

Solution

Look at MDC

Before actually starting processing, you should set up MDC with the information you mentioned You can then include this information in log messages

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>