C# Class Ms.Azure.Logging.Helpers.LoggingHelper

Helper class to initialize logging for Azure webroles, workerroles and webapplications
This class is meant to make it as easy as possible to enable logging, using just a few statements. Some defaults are chosen that might not fit all situations, such as a TransferInterval on the TableStorageAppender of 5 minutes.
Datei anzeigen Open project: martijns/Ms.Azure.Logging

Public Methods

Method Description
ClearAllLoggers ( ) : void

Clear all existing appenders and loggers

FlushAppenders ( ) : void

Flush any appenders that we know to support flushing. Typically used to flush the TableStorageAppender just before the application shuts down.

InitializeAzureTableLogging ( CloudStorageAccount storageAccount, string customTable = null, log4net.Core.Level logLevel = null ) : void

Initializes log4net with azure table logging.

InitializeAzureTableLogging ( StorageCredentials credentials, string customTable = null, log4net.Core.Level logLevel = null ) : void

Initializes log4net with azure table logging.

InitializeFileLogging ( string logfile, log4net.Core.Level logLevel = null ) : void

Initializes log4net with file logging.

InitializeFromConfiguration ( NameValueCollection config ) : void

Initializes logging from configuration. The NameValueCollection will read the following properties: - LogType: TableStorage or File - LogStorageName: account name for the storage account - LogStorageKey: key for the storage account - LogStorageTable: optional, customize the table to log to - LogFile: Filename to log to - LogStorageString: use a connection string to indicate storage account and credentials (makes LogStorageName and LogStorageKey obsolete and has preference)

Private Methods

Method Description
DetermineLevel ( string level ) : log4net.Core.Level

Converts a string loglevel to the correct type in order to configure an appender

Things would be so much easier and flexible if they would've made it an Enum or some collection

Method Details

ClearAllLoggers() public static method

Clear all existing appenders and loggers
public static ClearAllLoggers ( ) : void
return void

FlushAppenders() public static method

Flush any appenders that we know to support flushing. Typically used to flush the TableStorageAppender just before the application shuts down.
public static FlushAppenders ( ) : void
return void

InitializeAzureTableLogging() public static method

Initializes log4net with azure table logging.
public static InitializeAzureTableLogging ( CloudStorageAccount storageAccount, string customTable = null, log4net.Core.Level logLevel = null ) : void
storageAccount CloudStorageAccount
customTable string
logLevel log4net.Core.Level
return void

InitializeAzureTableLogging() public static method

Initializes log4net with azure table logging.
public static InitializeAzureTableLogging ( StorageCredentials credentials, string customTable = null, log4net.Core.Level logLevel = null ) : void
credentials StorageCredentials
customTable string
logLevel log4net.Core.Level
return void

InitializeFileLogging() public static method

Initializes log4net with file logging.
public static InitializeFileLogging ( string logfile, log4net.Core.Level logLevel = null ) : void
logfile string
logLevel log4net.Core.Level
return void

InitializeFromConfiguration() public static method

Initializes logging from configuration. The NameValueCollection will read the following properties: - LogType: TableStorage or File - LogStorageName: account name for the storage account - LogStorageKey: key for the storage account - LogStorageTable: optional, customize the table to log to - LogFile: Filename to log to - LogStorageString: use a connection string to indicate storage account and credentials (makes LogStorageName and LogStorageKey obsolete and has preference)
public static InitializeFromConfiguration ( NameValueCollection config ) : void
config System.Collections.Specialized.NameValueCollection
return void