Pete Freitag Pete Freitag

Push Tomcat logs with the AWS CloudWatch Logs Agent

Published on August 08, 2019
By Pete Freitag
javaweb

Earlier this week I wrote a tutorial for setting up CloudWatch Logs Agent to run on Ubuntu 18.04 . In that entry I setup the CloudWatch Logs Agent to send the /var/log/syslog file to CloudWatch Logs. In this howto we will look at sending Tomcat logs to CloudWatch Logs.

You will want to go through my previous article first, and then come back here, or if you are not using Ubuntu you will want to make sure you check the AWS docs for installing the CloudWatch Logs Agent on the OS you are using.

Adding Tomcat's catalina.out to CloudWatch Logs

To add a new log file we simply need to add a new entry in the amazon-cloudwatch-agent.json file (on my Ubuntu server it is located here: Ubuntu is located here: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json).

Add something like the following to the collect_list array in the json file:

{
	"file_path": "/var/log/tomcat8/catalina.out",
	"log_group_name": "web-server-log-group",
	"log_stream_name": "{hostname}/catalina.out",
	"timestamp_format" :"%d-%b-%Y %H:%M:%S.%f"
}

The key to adding new log files is to make sure that the timestamp_format is correct. You also want to make sure the log_group_name is set appropriately.

I also wrote a guide showing how to send nginx logs via the CloudWatch Logs Agent.



aws cloudwatch logs ubuntu tomcat

Push Tomcat logs with the AWS CloudWatch Logs Agent was first published on August 08, 2019.

If you like reading about aws, cloudwatch, logs, ubuntu, or tomcat then you might also like:

Weekly Security Advisories Email

Advisory Week is a new weekly email containing security advisories published by major software vendors (Adobe, Apple, Microsoft, etc).