App Container console logs are cutoff

mike010101 0 Reputation points
2024-04-19T03:01:40.03+00:00

My application writes logs as follows:

2024-04-18 22:44:35,588|8|INFO|mkt_data_loader.load_data|loading data: []
2024-04-18 22:44:35,915|8|INFO|mkt_data_loader.load_data|data loaded successfully
2024-04-18 22:44:35,938|8|INFO|mkt_data_loader.load_data|following ids where loaded: []

When i tail the logs from a console using:

az containerapp logs show -n my-app -g my-app-rg --type console --follow

I see logs like these:

{"TimeStamp":"2024-04-18T00:00:00","Log":"data: []"}
{"TimeStamp":"2024-04-18T00:00:00","Log":"loaded successfully"}
{"TimeStamp":"2024-04-18T00:00:00","Log":"ids where loaded: []"}

Can anyone tell if this is a bug or am i doing something wrong here?

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
324 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,258 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 15,701 Reputation points Microsoft Employee
    2024-05-11T04:32:17.6433333+00:00

    @mike010101 It seems like the logs are being formatted differently when you tail them from the console using the az containerapp logs show command. The logs are being displayed in JSON format with a TimeStamp and Log field. This is the expected behavior when you use the --type console option with the az containerapp logs show command.

    However, in your application logs, the logs are being formatted differently with a timestamp, log level, logger name, and log message separated by | characters. This is a common log format used by many logging frameworks.

    To make sure that your logs are formatted correctly, you can use a logging framework that supports JSON formatting. This will ensure that your logs are formatted consistently and can be easily parsed by tools that expect JSON-formatted logs.

    Alternatively, you can use a log aggregator like Azure Monitor or Log Analytics to collect and analyze your logs. These services can parse logs in various formats and provide powerful querying and visualization capabilities. You can configure your Azure Container Apps environment to send logs to Azure Monitor or Log Analytics by following the instructions in the Log storage and monitoring options in Azure Container Apps document.

    0 comments No comments