-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Windows Azure Websites Diagnostics Cmdlets
To be implemented
- Introduction to Azure Website Diagnostics
- Configure Azure Website Diagnostics Settings
- View Azure Website Log
- Download Azure Website Log
- Clear Azure Website Log
- References
These cmdlets are designed in a similar pattern of Get-WinEvent
.
Windows Azure Websites has just enabled some new diagnostics features. It allows you to write application logs in .NET and Node.js applications into 2 different locations:
- Azure Drive: a folder within Windows Azure Websites where logs are written into log files. This will
- Enable different log paths, like application or http.
- Enable path and full text matching.
- Enable log streaming.
- Only store at max 30MB logs.
- Be automatically turned off every 12 hours.
- Azure Table Storage: a table in some storage account where logs are written as table entities. This will enable
- Enable store more logs.
- Advanced query like query by log level and timestamp.
- Only store application logs.
The logs contain following information: timestamp, application name, event id, event tick count, level, message, pid and tid.
Here we are adding a few new cmdlets to Windows Azure PowerShell to support these new Azure Website diagnostics features.
Notice that accessing Azure Table Storage can have a billing impact. So all the cmdlets which access Azure Table Storage have some default values set up to make sure no large bill will be generated.
Set-AzureWebsite [-AzureDriveTraceEnabled [<Boolean>]] [-AzureDriveTraceLevel <Int32>]
[-AzureTableTraceEnabled [<Boolean>]] [-AzureTableTraceLevel <Int32>]
-
New Parameters
-
-AzureDriveTraceEnabled
: Determines whether writing logs to Azure Drive is enabled -
-AzureDriveTraceLevel
: Sets the trace level for Azure Drive diagnostics -
-AzureTableTraceEnabled
: Determines whether writing logs to Table Storage is enabled -
-AzureTableTraceLevel
: Sets the trace level of Azure Table diagnostics
-
- Output
- Verbose
The connection string of the Azure Storage account used by diagnostics can be configured via the existing -ConnectionStrings
parameter.
Get-AzureWebsiteLog [[-Max] <Int64>] [[-Level] <Int32[]>] [[-StartTime] <DateTime>] [[-EndTime] <DateTime>]
[[-Message] <String>] [[-Name] <String>]
Get-AzureWebsiteLog [[-Level] <Int32[]>] [[-Path] <String[]>] [[-Message] <String>] [[-Name] <String>]
[-Tail [<SwitchParameter>]]
Get-AzureWebsiteLog -ListPath [<SwitchParameter>]
-
Parameters
-
-Name
: Specify the name of the website you want to export the logs. If not provided, it will try to find the website name from cwd if it's a repo. Otherwise, it will fail. -
-Max
: Specifies the maximum number of logs that this cmdlet returns. Enter an integer. The default is to return the latest 100 logs.- It only works when Azure Table Storage Diagnostics is enabled.
- It cannot be used together with
-Tail
. - If it's used together with the query parameters (
-Level
,Path
,-StartTime
,-EndTime
and-Message
), the query parameters will always apply first.
-
Level <Int32[]>
: Specifies the levels of the logs you want to get. You can provide a single integer or an array of integers which indicates the levels.- Default is all levels.
- This parameter only works when Azure Table Storage Diagnostics is enabled.
-
Path <String[]>
: Specify the paths of the logs you want to get.- Default is Root which means all the paths.
- This parameter only works when Azure Drive Diagnostics is enabled.
-
StartTime <DateTime>
: Specifies the start time of the logs you want. Notice that this parameter only works when Azure Table Storage Diagnostics is enabled. -
EndTime <DateTime>
: Specifies the end time of the logs you want. Notice that this parameter only works when Azure Table Storage Diagnostics is enabled. -
Message <String>
: Specifies a string which will be used to match the log message. Only the logs which include this string will be returned. -
-Tail
: Set this cmdlet to log streaming mode.- It only works when Azure Drive Diagnostics is enabled.
- It cannot be used together with
-Max
.
-
-ListLogPath
: P2 Gets the list of log paths for the website.
-
- Output
2013-01-25T21:54:43 PID[8512] Error sample error
2013-01-25T21:54:44 PID[8512] Warning sample warning
2013-01-25T21:54:44 PID[8512] Information sample information
2013-01-25T21:54:44 PID[8512] Verbose sample message
- Verbose
-
Paging: Need to make sure this paging scenario works
Get-AzureWebsiteLog | Out-Host -Paging
Save-AzureWebsiteLog [[-Output] <String>] [[-Source] <String>] [[-Name] <String>]
-
New Parameters
-
-Output
: Specify where you want to put the exported logs. -
-Source
: Specify which log source you want to include. Possible values for now areazure storage
andfile drive
. Notice that the names for the values may change. -
-Name
: Specify the name of the website you want to export the logs. If not provided, it will try to find the website name from cwd if it's a repo. Otherwise, it will fail.
-
- Output
- Verbose
Clear-AzureWebsiteLog [[-FilterHashtable] <Hashtable[]>] [[-Name] <String>] [-Force [<SwitchParameter>]]
-
Parameters
-
EndTime
: Specifies the end time of the logs you want to delete. This parameter only works when Azure Table Storage Diagnostics is enabled. -
-Name
: Specify the name of the website you want to clear the logs. If not provided, it will try to find the website name from cwd if it's a repo. Otherwise, it will fail. -
-Force
: Force the cmdlet not to prompt for the operation.
-
- Prompt: By default the cmdlet will prompt the user to confirm the operation.
- Output
- Verbose