Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dss010101 opened this issue May 2, 2024 · 9 comments
Closed
Labels
Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. Container Instances az container ContainerApp customer-reported Issues that are reported by GitHub users external to the Azure organization. Service Attention This issue is responsible by Azure service team.

Comments

@dss010101
Copy link

dss010101 commented May 2, 2024

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 dss010101 added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label May 2, 2024
Copy link

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.

@azure-client-tools-bot-prd azure-client-tools-bot-prd bot added the Auto-Resolve Auto resolve by bot label May 2, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label May 2, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented May 2, 2024

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

@microsoft-github-policy-service microsoft-github-policy-service bot added Auto-Assign Auto assign by bot Container Instances az container Service Attention This issue is responsible by Azure service team. ContainerApp labels May 2, 2024
@dss010101
Copy link
Author

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

@Greedygre
Copy link
Contributor

Greedygre commented May 10, 2024

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

@dss010101
Copy link
Author

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
Copy link
Author

dss010101 commented May 10, 2024

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

@Greedygre
Copy link
Contributor

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

@dss010101
Copy link
Author

dss010101 commented May 10, 2024

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?

@Greedygre
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. Container Instances az container ContainerApp customer-reported Issues that are reported by GitHub users external to the Azure organization. Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

3 participants