Get-AzLog

Retrieves log events from Azure resources.

SYNOPSIS


Get-AzLog
    [-ResourceGroup string]
    [-ResourceId string]
    [-StartTime DateTime]
    [-EndTime DateTime]
    [-OperationName string]
    [-Caller string]
    [-SubscriptionId string]
    [-DefaultProfile IAzureContextContainer]
    [-Force]
    [-AsJob]
    [-WhatIf]
    [-Confirm]
        

DESCRIPTION

The Get-AzLog cmdlet retrieves log events from Azure resources. This cmdlet is useful for monitoring and auditing the activities performed on your Azure resources.

PARAMETERS

INPUTS

None

OUTPUTS

Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.AzureLog

The cmdlet outputs an object that represents a log event, containing properties such as:

EXAMPLES

Example 1: Get all logs for a resource group

This command retrieves all log events for the resource group named "MyResourceGroup".


Get-AzLog -ResourceGroup "MyResourceGroup"
            

Example 2: Get logs within a specific time range

This command retrieves log events for a specific resource ID between 2023-10-26 09:00:00 and 2023-10-26 17:00:00.


Get-AzLog -ResourceId "/subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/MyWebApp" `
    -StartTime "2023-10-26T09:00:00Z" -EndTime "2023-10-26T17:00:00Z"
            

Example 3: Get logs for a specific operation

This command retrieves all log events related to the 'Microsoft.Compute/virtualMachines/start/action' operation within your subscription.


Get-AzLog -OperationName "Microsoft.Compute/virtualMachines/start/action"
            

RELATED LINKS