We have a number of web apps hosted in Azure and I sometimes find it hard to follow the log streams (whether via the internal log stream GUI or via my own CLI) to to everything being one colour (bland yellow).
Is there a way to configure the azure commands in my CLI to highlight certain keywords (INFO, WARN, ERROR, etc) and make it slightly easier for the human eye to follow?
I've tried to add my own om-my-zsh themes but as the Azure response is one large reactive console log (to my understanding) this bypasses my own terminal config.
As of now, Azure CLI and the portal's log streaming feature do not natively support customizing log colors or highlighting specific keywords. However, you can use the portal to filter out the type of log you want to view to clear the clutter for your ease of viewing.
For example-
Let's say I am using a webapp which is up and running
Now if I just want to check informational log then under log stream of your webapp
Same way if I want for warning or error, I can filter it out accordingly.
Separately coloring inside azure cli or the portal not possible. But if you know what you are specifically looking for then such similar keywords with GREP command will highlight it.
Example-
az webapp log tail --name <app_name> --resource-group <resource_group> | \
grep --color=always -E "INFO|WARN|ERROR|$"
or from your local bash shell once you are connected to azure using azure login, try running
if it supports then
az webapp log tail --name LogStreamApp --resource-group arkorg | \
sed -E 's/INFO/\x1b[32m&\x1b[0m/g; s/WARN/\x1b[33m&\x1b[0m/g; s/ERROR/\x1b[31m&\x1b[0m/g'
I picked the color codes from here
Please check out the colorization guidelines from Azure and How to change text colours in iTerm2 - Stack Overflow for better clarity.