-
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
- Enable Azure Website Diagnostics
- Disable Azure Website Diagnostics
- 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.
This cmdlet is used to enable application diagnostics for Azure Website.
Enable-AzureWebsiteApplicationDiagnostic [-File] <SwitchParameter>
[-LogLevel <AzureWebsiteDiagnosticLogLevel> {Error | Warning | Information | Verbose}]
Enable-AzureWebsiteApplicationDiagnostic [-Storage] <SwitchParameter>
[-LogLevel <AzureWebsiteDiagnosticLogLevel> {Error | Warning | Information | Verbose}]
[-StorageAccountName] <String>
-
Parameters
-
-File
: Specifies the output of the log is file system. -
-Storage
: Specifies the output of the log is storage table. -
-LogLevel
: Specifies the log level. Supported values areError
,Warning
,Information
andVerbose
. -
-StorageAccountName
: Specifies which storage account to store the log. If not specified, will use the current storage account of the subscription.
-
- Output
- Verbose
This cmdlet is used to disable site and application diagnostics for Azure Website.
Disable-AzureWebsiteDiagnostic -Type [<AzureWebsiteDiagnosticType> {Site | Application}]
Disable-AzureWebsiteDiagnostic -Type Site [-WebServerLogging [<SwitchParameter>]]
[-DetailedErrorMessages [<SwitchParameter>]] [-FailedRequestTracing [<SwitchParameter>]]
Disable-AzureWebsiteDiagnostic -Type Application [-Output [<AzureWebsiteDiagnosticOutput> {FileSystem | StorageTable}]]
-
Parameters
-
-Type
: Specifies what kind of diagnostics to disableSite
orApplication
-
-
Dynamic Parameters: Depends on the value of the
-Type
parameter, following are the dynamic parameters one can use-
-Type Site
: If no dynamic parameter is specified, the cmdlet will disable all three.-
-WebServerLogging
: Disables web server logging -
-DetailedErrorMessages
: Disables detailed error messages -
-FailedRequestTracing
: Disables failed request tracing
-
-
-Type Application
-
-Output
: Specifies where to store the log. Supported values areFileSystem
andStorageTable
. If not specified, the cmdlet will disable both.
-
-
-
Output
-
Verbose
Notice that multiple calls to this cmdlet with different parameters won't overwrite each other. So the following 2 scripts are the same
# 1
Disable-AzureWebsiteDiagnostic -Type Site -WebServerLogging
Disable-AzureWebsiteDiagnostic -Type Site -DetailedErrorMessages
# 2
Disable-AzureWebsiteDiagnostic -Type Site -WebServerLogging -DetailedErrorMessages
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
.
-
-ListPath
: 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