diff --git a/ebextensions/tomcatlogs.config b/ebextensions/tomcatlogs.config index 49428f9..8a3b3e6 100644 --- a/ebextensions/tomcatlogs.config +++ b/ebextensions/tomcatlogs.config @@ -3,7 +3,7 @@ #### the Log Stream name as the instance id. The following files are examples of logs that will be #### streamed to CloudWatch Logs in near real time: #### -#### /var/log/tomcat8/catalina.out +#### /var/log/tomcat/catalina.out #### #### You can then access the CloudWatch Logs by accessing the AWS CloudWatch Console and clicking #### the "Logs" link on the left. The Log Group name will follow this format: @@ -14,6 +14,10 @@ #### http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.cloudwatchlogs.html ################################################################################################### +packages: + yum: + awslogs: [] + files: "/etc/awslogs/config/tomcatlogs.conf" : mode: "000644" @@ -23,9 +27,32 @@ files: [/var/log/tomcat8/catalina.out] log_group_name=`{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/tomcat8/catalina.out"]]}` log_stream_name={instance_id} - file=/var/log/tomcat8/catalina.out* + file=/var/log/tomcat/catalina.out* + + "/etc/rsyslog.d/catalina.conf": + mode: "0644" + owner: root + group: root + content: | + #redirect tomcat logs to /var/log/tomcat/catalina.out discarding timestamps since the messages already have them + template(name="catalinalog" type="string" + string="%msg%\n") + if $programname == 'server' then { + *.=warning;*.=err;*.=crit;*.=alert;*.=emerg /var/log/tomcat/catalina.out;catalinalog + *.=info;*.=notice /var/log/tomcat/catalina.out;catalinalog + } commands: - "01_restart_awslogs": - command: service awslogs restart + "02a_systemctl_start_awslogsd": + command: systemctl start awslogsd + ignoreErrors: true + + "02b_systemctl_enable_awslogsd_service": + command: systemctl enable awslogsd.service + ignoreErrors: true + + "02c_restart_awslogs": + command: service awslogsd restart + "03_restart_rsyslog": + command: systemctl restart rsyslog