DEV Community

Ashutosh Mishra
Ashutosh Mishra

Posted on

Send Azure WebApp Logs to the Azure Blob Storage Using Diagnostic Setting

I have deployed a simple flask web app to the azure AppService and it is working fine, now i have to connect blob storage to it to save the logs to the blob storage.

from flask import Flask,request

app = Flask(__name__)

from flask import jsonify
import logging

logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s")
logger = logging.getLogger(__name__)
@app.route("/api1")
def api1():
    print("hello data is getting printed")
    logger.info("API1 endpoint called. Hello, data is getting printed.")
    return jsonify("Hello World")

Enter fullscreen mode Exit fullscreen mode

I am able to get log file in the blob storage but i am getting only the print statement only not the
logger

{ "time": "2024-09-20T04:47:50.8864337Z", "resultDescription": "hello data is getting printed", "resourceId": "/SUBSCRIPTIONS//RESOURCEGROUPS/FLASKNEW_GROUP/PROVIDERS/MICROSOFT.WEB/SITES/FLASKNEW", "containerId": "flasknew_06688305", "operationName": "Microsoft.Web/sites/log", "category": "AppServiceConsoleLogs", "level": "Informational", "location": "Central India", "EventStampType": "Stamp", "EventPrimaryStampName": "aaa-prod-cvf-023", "EventStampName": "waws-prod-pn1-023", "Host": "lw0sdlwk000BPK", "EventIpAddress": "1111"}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)