Welcome to the Microsoft Q&A Platform!
The issue you're facing seems to be related to the misclassification of log levels in Azure App Service Console Logs.
Ensure your logging levels are set correctly in the Python app.
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.info("This is an INFO log.")
logger.error("This is an ERROR log.")
Go to Azure Portal > App Service > Diagnostic Settings.
Ensure logs for Application Logs and Console Logs are enabled and categories are correctly configured.
If using middleware Pass the correct log level when starting the application.
uvicorn app.main:app --log-level info
Implement a handler to explicitly map log levels.
class AzureLogHandler(logging.Handler):
def emit(self, record):
level = record.levelname
if level == "INFO":
print(f"INFO:{record.getMessage()}")
elif level == "ERROR":
print(f"ERROR:{record.getMessage()}")
handler = AzureLogHandler()
logger.addHandler(handler)
Use Log Analytics Workspace to query log levels with KQL.
AppServiceConsoleLogs
| where Level == "Error"
| project TimeGenerated, ResultDescription, Level
Use Application Insights or third-party tools (e.g., ELK Stack) to validate the log levels independently.
ref: Python Logging Documentation
https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/diagnostic-settings
https://learn.microsoft.com/en-us/kusto/query/kql-quick-reference?view=azure-data-explorer&preserve-view=true
https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview
https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request
If the answer is helpful, please click ACCEPT ANSWER and kindly upvote