简体   繁体   English

是否可以使用 Logback 为每个日志事件添加序列号?

[英]Is it possible to add a sequential number to each log event using Logback?

I have an ELK mounted and my app send logs use Logback.我安装了 ELK,我的应用程序使用 Logback 发送日志。 The problem is that I loose the events order when there are many logs with the same timestamp (many fast events in the same millisecond).问题是当有许多具有相同时间戳的日志(同一毫秒内的许多快速事件)时,我会丢失事件顺序。

I would like to add a sequential number to keep the log events order when there is many logs at the same time.当同时有许多日志时,我想添加一个序列号以保持日志事件的顺序。 Is that possible?那可能吗? How?如何?

Thank you and sorry for my English.谢谢你,对不起我的英语。


EDIT:编辑:

Sorry, I give more information about the scenario: I'm using a Springboot application which sends the logs to an ELK (Elastic-Logstash-Kibana) stack.抱歉,我提供了有关该场景的更多信息:我正在使用 Springboot 应用程序,它将日志发送到 ELK (Elastic-Logstash-Kibana) 堆栈。

I need to add a field with the sequence number so then I'll be able to order the logs in Kibana using that field.我需要添加一个带有序列号的字段,这样我就可以使用该字段在 Kibana 中订购日志。 Currently Kibana is ordering the logs by timestamp field but sometimes there is too many logs at the same time.目前 Kibana 正在按时间戳字段对日志进行排序,但有时同时存在太多日志。 The logs at the same time are unordered.同时的日志是无序的。

You can use custom log pattern.您可以使用自定义日志模式。 Please follow below link.请按照以下链接。 https://reflectoring.io/logging-format-logback/ https://reflectoring.io/logging-format-logback/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM