Search code examples
azureloggingazure-sql-databaseazureazure-blob-storage

Azure SQL storing database logs


For storing Azure SQL database logs, is it necessary to explicitly create blob for logs storage or it is implicitly created. I read this and this post but still not sure about it?

Also, for Java/Spring application deployed in App Services, when using App Insights, Log Analytics and Azure Monitor for Application logs, HTTP and Access logs and DB logs, do I need to explicitly setup blob for storing logs?


Solution

  • No, you do not need to create a blob storage for Azure SQL database logs as they are stored in Azure SQL database transaction logs and can be viewed using Azure Monitor or audited using Azure SQL Auditing.

    Steps to check the Logs in SQL DB under Monitor section.

    1. After creating azure SQL database and server.
    2. Go to monitoring tab as mentioned in below screenshot and the logs can be viewed.

    enter image description here

    Approach 2

    Using Log Analytics

    1. Create a Log analytics workspace in Azure.
    2. And go to the SQL Database and choose the Diagnostics from left pane in monitoring tab.

    enter image description here

    1. Add a diagnostic setting and choose the created log analytics and choose the log option as mentioned in below screenshot.

    enter image description here

    1. You can find the logs as shown below.

    enter image description here

    To store the Azure SQL Logs explicitly

    1. You need to create 'Storage Account' for storing logs.

    2. And have to enable Azure Monitor Logs from your SQL server and select 'Diagnostic logs' from the Azure Monitor menu and then, turn on the logs and select the storage account you created.

    3. And configure log retention by selecting the Logs tab in the Azure Monitor menu, and then choose 'Retention policy' to configure how long logs will be retained.

    4. To verify logs in the storage account, go to the storage account and select 'Containers.' You should see a container named 'insights-logs-sqlserverauditlog.' You can then browse the logs stored in this container.