Drop-wizard 日志格式中的“X{code}”是什么意思
What is the meaning of `X{code}` in Drop-wizard log format
抱歉,如果我在这里问的是非常基本的问题。但我使用的是 dropwizard 应用程序,其中日志格式为 "%-6level [%d{HH:mm:ss.SSS}] [%t] %logger{5} - %X{code} %msg %n"
。
应用程序日志包含以下几行:-
INFO [2017-06-07 13:54:43,828] com.foo.Bar: In Get Method
我理解 %-6level , date and %t and %msg %n
在日志格式中的含义,但无法理解 %X{code} 和 %logger{ 的含义5} 并且没有在我的日志中看到这些内容。
谁能给我指点一个合适的文档,其中详细解释了日志格式的每个参数。
这是一个关于 logback 布局的很好的文档:Layouts
对于 logger{length}
部分:
Outputs the name of the logger at the origin of the logging event.
This conversion word takes an integer as its first and only option.
The converter's abbreviation algorithm will shorten the logger name,
usually without significant loss of meaning. Setting the value of
length option to zero constitutes an exception. It will cause the
conversion word to return the sub-string right to the rightmost dot
character in the logger name. The next table provides examples of the
abbreviation algorithm in action.
对于 X{key:-defaultVal}
部分:
Outputs the MDC (mapped diagnostic context) associated with the thread
that generated the logging event.
可以在此处找到有关 MDC 的更多信息:Mapped Diagnostic Context
根据您的配置,您可以这样称呼它,例如:
MDC.put("code", "whateverCode");
抱歉,如果我在这里问的是非常基本的问题。但我使用的是 dropwizard 应用程序,其中日志格式为 "%-6level [%d{HH:mm:ss.SSS}] [%t] %logger{5} - %X{code} %msg %n"
。
应用程序日志包含以下几行:-
INFO [2017-06-07 13:54:43,828] com.foo.Bar: In Get Method
我理解 %-6level , date and %t and %msg %n
在日志格式中的含义,但无法理解 %X{code} 和 %logger{ 的含义5} 并且没有在我的日志中看到这些内容。
谁能给我指点一个合适的文档,其中详细解释了日志格式的每个参数。
这是一个关于 logback 布局的很好的文档:Layouts
对于 logger{length}
部分:
Outputs the name of the logger at the origin of the logging event. This conversion word takes an integer as its first and only option. The converter's abbreviation algorithm will shorten the logger name, usually without significant loss of meaning. Setting the value of length option to zero constitutes an exception. It will cause the conversion word to return the sub-string right to the rightmost dot character in the logger name. The next table provides examples of the abbreviation algorithm in action.
对于 X{key:-defaultVal}
部分:
Outputs the MDC (mapped diagnostic context) associated with the thread that generated the logging event.
可以在此处找到有关 MDC 的更多信息:Mapped Diagnostic Context
根据您的配置,您可以这样称呼它,例如:
MDC.put("code", "whateverCode");