我有一个包含日志 log4j 的文件,我无法为 logstash 编写过滤器,它将返回仅包含 JSON 的日志
input {
file {
path => "C:/logs/inlog.log"
}
}
filter {
#A lot of what I tried to write
}
output {
file {
path => "C:/logs/outlog.log"
}
}
因此,我们需要一个过滤器来显示包含 json 的日志。Json 日志被标记为 trace
示例日志:
[2019/08/02 11:21:52.472 MSK] [ 4] INFO ru.dmko.logstash.util.Utils - Initialized timer 'MyProject' with interval - 60000
[2019/08/02 11:21:53.769 MSK] [ 4] INFO ru.dmko.logstash.EventHandlerBean - EventHandler started
[2019/08/02 11:21:56.535 MSK] [21] INFO ru.dmko.logstash.processors.MessageProcessorBean - {"glossary": {"title": "example glossary", "GlossDiv": {"title": "S", "GlossList": {"GlossEntry": {"ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"]}, "GlossSee": "markup"}}}}
[2019/08/02 11:21:56.551 MSK] [21] INFO ru.dmko.logstash.processors.MessageProcessorBean - Equal messages
[2019/08/02 11:21:56.613 MSK] [21] INFO ru.dmko.logstash.processors.MessageProcessorBean - {"glossary": {"title": "example glossary", "GlossDiv": {"title": "S", "GlossList": {"GlossEntry": {"ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"]}, "GlossSee": "markup"}}}}
其中,只需要看到两个包含json
江户川乱折腾
相关分类