问题
I want to display all values set in MDC in log file in json format in log4j 1.2 version.
This is third party's log4j.properties
file I'm modifying so I can't change anything other than this log4j.properties file, I mean I can't add any other dependency like to help this log4j to support MDC and json format.
I can print values using %X{PARAMETER_NAME}
but can't get all MDC values at once.
log4j.appender.ReportsExecutionLog = org.apache.log4j.RollingFileAppender
log4j.appender.ReportsExecutionLog.layout = org.apache.log4j.PatternLayout
log4j.appender.ReportsExecutionLog.File = ../logs/ReportsExecutionLog.json
log4j.appender.ReportsExecutionLog.Threshold=INFO
#log4j.appender.ReportsExecutionLog.layout.ConversionPattern=%m - ReportName=%X{REPORT_NAME} %n
I'm looking for something like below
log4j.appender.ReportsExecutionLog.layout.ConversionPattern={"%m" - "%X" }%n
But this is not giving me anything for %X
来源:https://stackoverflow.com/questions/59634856/how-to-log-all-values-set-in-mdc-in-json-format-using-log4j-properties-file-in-l