azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

command az container and container app logs - log line are getting cut off

Open dss010101 opened this issue 1 year ago • 9 comments

Describe the bug

I have a python app that i run in both a Container App container as well as a Container App Job container. The application writes logs to both the console and a file 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 use the following from the console: az containerapp logs show -n <container app name> -g <resource group> --type console --tail 30

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: []"}

When i log into a vm that has the fileshare mounted where the logs are written, i see the logs in the file as they should appear. Furthermore, when looking at these same logs from portal.azure either using logstream or console i see the logs as they should appear -the full line is shown.

I wonder if the issue may be the | character?

Related command

az containerapp logs show -n -g --type console --tail 30 az containerapp logs show -n -g --type console --follow

Errors

None

Issue script & Debug output

None

Expected behavior

Expect to see entire log line

Environment Summary

azure-cli 2.59.0 *

core 2.59.0 * telemetry 1.1.0

Extensions: log-analytics 0.2.2

Dependencies: msal 1.27.0 azure-mgmt-resource 23.1.0b2

Python location '/opt/az/bin/python3' Extensions directory '/root/.azure/cliextensions'

Python (Linux) 3.11.8 (main, Mar 27 2024, 04:03:49) [GCC 12.2.0]

Additional context

No response

dss010101 avatar May 02 '24 05:05 dss010101

Hi @dss010101,

2.59.0 is not the latest Azure CLI(2.60.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

Thank you for opening this issue, we will look into it.

yonzhan avatar May 02 '24 05:05 yonzhan

Hi @dss010101,

2.59.0 is not the latest Azure CLI(2.60.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

same issue on 2.60.0

dss010101 avatar May 02 '24 05:05 dss010101

Hi @dss010101

I notice in the help, the default value of --format is json, can you try to specify it with --format text? az containerapp logs show -h

--format : Log output format. Allowed values: json, text. Default: json.

Thanks

Greedygre avatar May 10 '24 03:05 Greedygre

Hi @dss010101

Thanks for reporting this issue. I notice in the help, the default value of --format is json, can you try to specify it with --format text? az containerapp logs show -h

--format : Log output format. Allowed values: json, text. Default: json.

Thanks

using that option with 'text' shows the entire line. the default does not.

dss010101 avatar May 10 '24 05:05 dss010101

is the recommendation to log as json for the default case? or is this bug?

dss010101 avatar May 10 '24 19:05 dss010101

using that option with 'text' shows the entire line. the default does not.

As the format option mentioned, the default format is json, this is by design and not a bug::

--format : Log output format. Allowed values: json, text. Default: json. Thanks

Greedygre avatar May 10 '24 23:05 Greedygre

I guess my question is...if we want to use app containers, are expected to modify our application to log in json format instead of text? Is that the recommendation?

dss010101 avatar May 10 '24 23:05 dss010101

I guess my question is...if we want to use app containers, are expected to modify our application to log in json format instead of text? Is that the recommendation?

I haven't found a recommendation for this, it depends on your needs. It’s just that the in CLI output here defaults to json format, so if your application outputs text format, you need to specify the text format with az containerapp logs show --format text.

Greedygre avatar May 10 '24 23:05 Greedygre