forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 2
Windows Azure Websites Diagnostics Cmdlets
guangyang edited this page Feb 28, 2013
·
25 revisions
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
-
New Parameters (Naming TDB, waiting for Azure Portal design)
- Enabling Diagnostics for Azure Drive
- Verbosity level for Azure Drive Diagnostics
- Enabling Diagnostics to Table Storage
- Verbosity level of Table diagnostics
- Set Table storage to be used for the Diagnostic data
- Output
- Verbose
Get-AzureWebsiteLog [[-Max] <Int64>] [[-FilterHashtable] <Hashtable[]>] [[-Name] <String>]
Get-AzureWebsiteLog [[-FilterHashtable] <Hashtable[]>] [[-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
-FilterHashtable
,-FilterHashtable
will always apply first.
-
-FilterHashtable
: Uses a query in hash table format to select logs. The query contains a hash table with one or more key-value pairs. Hash table queries have the following rules:- Keys and values are case-insensitive.
- Each key can be listed only once in each hash-table.
- Only support path and message string matching for Azure Drive Diagnostics
- Support advanced query for Azure Table Storage Diagnostics
- The valid key-value pairs are as follows:
-
Level <Int32[]>
: Specify 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>] [[-FilterHashtable] <Hashtable[]>]
[[-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. -
-FilterHashtable
: P2 Uses a query in hash table format to select logs. The query contains a hash table with one or more key-value pairs. Hash table queries have the following rules:- Keys and values are case-insensitive.
- Each key can be listed only once in each hash-table.
- Only support path and message string matching for Azure Drive Diagnostics
- Support advanced query for Azure Table Storage Diagnostics
- The valid key-value pairs are as follows:
-
Level <Int32[]>
: Specify 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.
- 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.- Default value is
DateTime.now.AddDays(-1)
. - This parameter only works when Azure Table Storage Diagnostics is enabled.
- Default value is
-
EndTime <DateTime>
: Specifies the end time of the logs you want.- Default value is
DateTime.now
. - This parameter only works when Azure Table Storage Diagnostics is enabled.
- Default value is
-
-
-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
-
-FilterHashtable
: Uses a query in hash table format to select logs. The query contains a hash table with one or more key-value pairs. Hash table queries have the following rules:- Keys and values are case-insensitive.
- Each key can be listed only once in each hash-table.
- Only support path and message string matching for Azure Drive Diagnostics
- Support advanced query for Azure Table Storage Diagnostics
- The valid key-value pairs are as follows:
-
StartTime
: Specifies the start time of the logs you want.- Default value is
DateTime.now.AddDays(-1)
. - This parameter only works when Azure Table Storage Diagnostics is enabled.
- Default value is
-
EndTime
: Specifies the end time of the logs you want.- Default value is
DateTime.now
. - This parameter only works when Azure Table Storage Diagnostics is enabled.
- Default value is
-
-
-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