使用 MuleSoft Runtime 4.4 进行 MDC 日志记录
MDC Logging With MuleSoft Runtime 4.4
我在 Anypoint Studio 中遇到 MDC 问题。我使用 Runtime 4.4 中的新模块在记录器中设置变量,但它不起作用。在控制台中,我有这样的输出。但是在文档中我发现记录器也应该像这样向我显示这个设置变量:
信息 2021-04-08 16:58:26,882 [[MuleRuntime].uber.15: [test-project-app].exmapleFlow.CPU_LITE @18f679] [{ correlationId=c85e16c0-98a4-11eb-bc34-cac765a2219b, processorPath=exmapleFlow/processors/2, testVar=testValue}] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 例子
enter image description here
您必须编辑 log4j2.xml。默认值是这样的:
[processor: %X{processorPath}; event: %X{correlationId}]
但是你需要这样的东西:
[%MDC]
它实际上在文档中:https://docs.mulesoft.com/mule-runtime/4.4/logging-mdc#example-log4j2-xml-file-configurations
您必须更改 log4j2.xml appender 以及 %MDC。
找到下面的工作示例 link,我相信如果您按照下面的步骤进行操作,它一定会工作 link。
https://help.mulesoft.com/s/question/0D52T00005aW7E2SAK/mdc-logging-in-mulesoft-runtime-44
我在 Anypoint Studio 中遇到 MDC 问题。我使用 Runtime 4.4 中的新模块在记录器中设置变量,但它不起作用。在控制台中,我有这样的输出。但是在文档中我发现记录器也应该像这样向我显示这个设置变量:
信息 2021-04-08 16:58:26,882 [[MuleRuntime].uber.15: [test-project-app].exmapleFlow.CPU_LITE @18f679] [{ correlationId=c85e16c0-98a4-11eb-bc34-cac765a2219b, processorPath=exmapleFlow/processors/2, testVar=testValue}] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 例子
enter image description here
您必须编辑 log4j2.xml。默认值是这样的:
[processor: %X{processorPath}; event: %X{correlationId}]
但是你需要这样的东西:
[%MDC]
它实际上在文档中:https://docs.mulesoft.com/mule-runtime/4.4/logging-mdc#example-log4j2-xml-file-configurations
您必须更改 log4j2.xml appender 以及 %MDC。
找到下面的工作示例 link,我相信如果您按照下面的步骤进行操作,它一定会工作 link。
https://help.mulesoft.com/s/question/0D52T00005aW7E2SAK/mdc-logging-in-mulesoft-runtime-44