gpt4 book ai didi

Log4J2 JSONLAYOUT 如何添加自定义参数

转载 作者:行者123 更新时间:2023-12-04 13:52:41 25 4
gpt4 key购买 nike

如何在 Log4j2 的 JSONLAYOUT 中添加自定义参数?

还有没有办法向 JSONLAYOUT 的消息元素添加模式?

我已经尝试了这里列出的选项 ->
logging.apache.org/log4j/2.x/manual/layouts.html#JSONLayout

请帮忙!

最佳答案

解决方案是显式添加 log4j2 的 2.10.0 版本。此版本支持 JSONLayout 中的自定义参数!

<Appenders>

<Console name="Console" target="SYSTEM_OUT">
<JSONLayout compact="true" eventEol="true">
<KeyValuePair key="application" value="${sys:com.example.appname}"/>
</JSONLayout>
</Console>
<Async name="AsyncAppender" bufferSize="80">
<AppenderRef ref="Console"/>
</Async>

</Appenders>

关于Log4J2 JSONLAYOUT 如何添加自定义参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47232747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com