Search code examples
amazon-elastic-beanstalkamazon-cloudwatchlogs

adding metric in cloudwatch log


Elastic Beanstalk generated logs in five file by default. When cloudwatch streaming log is enabled it shows error.log access.log, eb.log. But i want catilina.out log or tomcat log also in cloudwatch log. How to do it?


Solution

  • You can add your own logs to Cloudwatch using an additional configuration file:

    /etc/awslogs/config/awslogs.conf
    

    As an example I use the following file to steam all the laravel logs for an application to cloudwatch:

    [laravel.log]
    file = /var/www/html/storage/logs/laravel*
    buffer_duration = 5000
    log_stream_name = {instance_id}
    initial_position = start_of_file
    log_group_name = prod-laravel
    multi_line_start_pattern = {datetime_format}
    

    When adding or updated the file be sure to restart the awslogs daemon too.

    More information can be found at https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AgentReference.html.