java - JSONLayout endOfLine 属性未按预期工作
问题描述
我在我的项目的 log4j2.xml 文件中使用此配置以在一行中获取 JSON 格式的日志:
<JsonLayout compact="true" eventEOL="true" endOfLine="\n" properties="true"/>
\r\n
使用时默认情况下,每一行都由 分隔eventEOL="true"
,但是我不希望\r
使用.endOfLine
\n
我希望日志以新行发出,而是\n
打印为字符串。
预期的:
{"message":"I want this"}
{"message":"new log in new line"}
当前行为:
{"message":"I want this"}\n{"message":"new log in new line"}
注意:我不想要的原因\r
是因为 Splunk 无法解析\r
事件文本中带有 (#015) 的 JSON 日志。
相关文档:https ://logging.apache.org/log4j/2.x/manual/layouts.html#JSONLayout
任何建议表示赞赏。
解决方案
推荐阅读
- angular - ReferenceError:未定义 HTMLAnchorElement Angular 7 Universal
- python - 将 JSON 数据从 Google Analytics 保存到关系数据库的最佳方法
- python - 将 Series 传递给 Series.map() 时的 NaN 值
- opencv - 如何从 Yocto 图像中排除 opencv 编译?
- perforce - 未经检查修改的文件未在 p4v 工作区中标记为已修改
- javascript - 如何触发动态创建的元素的事件?
- ios - 如何从 json alamofire 在选择器视图中添加内容,我想选择访问者类型作为选择器视图,以便我想在数组中获取它
- c# - 为什么 Microsoft.NetCore.Analyzers CA2000 中的分析结果有差异
- aws-sdk - 带有 AWS SDK 2 for Java 的 Min.io 拒绝正常工作
- php - 使用 php 获取输入字段的 id 并将其设置在变量中