I have an Elastic Beanstalk app running a .Net app through IIS in a Windows environment. I want to get my custom logs to show up in AWS CloudWatch.
The app uses a Serilog logger in one of its static classes.
The logger outputs a message when I go to an endpoint path (ex. "/api/log-a-message").
Logs are written to a file "C:\LogsFolder\LogFile.log".
Following some online searching and reading through other questions and the AWS Documents. I ended up writing a .ebextensions/log_configuration.conf
with the following content:
### BEGIN .ebextensions/CloudWatch.config
files:
"C:/Program Files/Amazon/ElasticBeanstalk/config/taillogs.d/":
content: |
[ZeW logs]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "Serilog"]]}`
log_stream_name = {instance_id}
file = C:/LogsFolder/LogFile.log
### END .ebextensions/CloudWatch.config
But the logs are still not appearing in CloudWatch.
CloudWatchAgentServerPolicy
andAmazonEC2RoleforSSM
policies added to the aws-elasticbeanstalk-ec2-role, though it looks like the latter is deprecated in favor ofAmazonSSMManagedInstanceCore
. – littleforestchkconfig awslogs on
, and thenservice awslogs restart
. – littleforest.ebextensions/CloudWatch.config
file gets flung to, otherwise I could just use theappendConf
option – ZeW