我对Cloud Watch上的日志有问题。我一直把日志放在不同的条目上,而不是每个日志一个条目。下面是一个例子。
控制台输出:
[2020-12-21T11:51:21.966] [ERROR] default - [handlerProcess] [
ValidationError {
target: OnBroadcastStart {
broadcast_id: 'bro_...',
session_id: null,
timestamp: '2020-12-21T11:51:21.920Z'
},
value: null,
property: 'session_id',
children: [],
constraints: {
isNotEmpty: 'session_id should not be empty',
isString: 'session_id must be a string'
}
}
]
This is the output from a single error log.
云监控输出:
[2020-12-21T11:51:21.966] [ERROR] default - [handlerProcess] [
[2020-12-21T11:51:21.966] ValidationError {
[2020-12-21T11:51:21.966] target: OnBroadcastStart {
[2020-12-21T11:51:21.966] broadcast_id: 'bro_...',
[2020-12-21T11:51:21.966] session_id: null,
[2020-12-21T11:51:21.966] timestamp: '2020-12-21T11:51:21.920Z'
[2020-12-21T11:51:21.966] },
[2020-12-21T11:51:21.966] value: null,
[2020-12-21T11:51:21.966] property: 'session_id',
[2020-12-21T11:51:21.966] children: [],
[2020-12-21T11:51:21.966] constraints: {
[2020-12-21T11:51:21.966] isNotEmpty: 'session_id should not be empty',
[2020-12-21T11:51:21.966] isString: 'session_id must be a string'
[2020-12-21T11:51:21.966] }
[2020-12-21T11:51:21.966] }
[2020-12-21T11:51:21.966] ]
每一行都是这里的入口。
有什么办法解决这个问题吗?作为该项目的记录器,我使用Log4js。
因此,如果您正在使用Cloudwatch Agent,则需要调整Timestamp_format设置。如果您没有指定格式,CloudWatch将使用特定于epoch的时间戳和日期对日志的每一行进行ping。
要调整代理设置,您可以在此处找到信息:https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html