AWS:Java应用程序记录到AWS Cloudwatch

问题描述 投票:0回答:1

我有使用Java,Jersey2和AWS实现的RESTful API的集合。目前,我已经使用SL4J配置了日志,该日志登录到本地文件。是否可以将这些日志发送到cloudwatch,以便我可以更好地监视日志并在将来需要时实施警报?

java amazon-web-services jersey-2.0 amazon-cloudwatch amazon-cloudwatchlogs
1个回答
0
投票

您需要在实例上将install CloudWatch Log Agent并配置为监视日志文件,方法是在/etc/awslogs/config/中创建这样的配置文件:

[mylogfile.log]
datetime_format = %m/%d/%y-%H:%M:%L
file = /folder/mylogfile.log
buffer_duration = 5000
log_stream_name = {instance_id}-{hostname}-{ip_address}-mylogfile.log
initial_position = start_of_file
log_group_name = MyApplicationLogGroup

这里是带有日志记录和监视的完整示例:https://github.com/antonum/CloudWatch-IRIS

© www.soinside.com 2019 - 2024. All rights reserved.