forked from martijns/Ms.Azure.Logging
-
Notifications
You must be signed in to change notification settings - Fork 0
neilsb/Ms.Azure.Logging
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
.------------------------------------------------------------ | TableStorageAppender for log4net | | Author: Martijn Stolk | Website: http://martijnstolk.blogspot.com | Date: December 30th, 2014 | Version: 2.0 | License: Creative Commons Attribution 3.0 Unported (CC BY 3.0) | http://creativecommons.org/licenses/by/3.0/ }------------------------------------- | Changes | | v2.0 (December 30th, 2014) | - Support "LogStorageString" for a connection string as alternative to Name/Key | - Updated dependencies to Azure SDK 2.4 | - Fix compatibility issue in PartitionKey and RowKey being different from how WAD writes | them, making some tools incompatible. | | v1.3 (July 2nd, 2013) | - Add support for CloudStorageAccount | - Add support for DeveloperStorage (when not using CloudStorageAccount), by using | storage account credentials where the username starts with "devstoreaccount" | | v1.2 (June 27th, 2013) | - Updated to use Azure SDK 2.0 | - Added NuGet dependency for WindowsAzure.Storage (v2.0 or higher) | | v1.1 (February 8th, 2013) | - Fixed problem with references | | v1.0 (February 2nd, 2013) | - Initial public release | }------------------------- | An appender for log4net that helps you log to an Azure Storage Table. This appender | can be used as a generic solution for Azure Websites, Azure Webroles and Azure | Workerroles or even any desktop application for which you want the logs to end | up in a storage account. | | The format in which the messages are saved is compatible with the existing Windows | Azure Diagnostics (wad) format. Hence any applications that makes use of this will | function with this appender as well. | | For now the appender must be configured via code. Configuration via an | app/web/log4net.config file is not (yet) supported. | | Easiest example: | // At application startup | var credentials = new StorageCredentials(storageName, storageKey); | LoggingHelper.InitializeAzureTableLogging(credentials); | | // Just use the logger as you're used to | ILog logger = LogManager.GetLogger("MyLogger"); | logger.Info("My Info Logmessage"); | | // And at application shutdown to make sure everything is saved before exiting | LoggingHelper.FlushAppenders(); | | Custom log4net configuration: | var credentials = new StorageCredentials(storageName, storageKey); | var appender = new TableStorageAppender(credentials) | { | Layout = layout, | Threshold = Level.Debug, | Name = "TableStorageAppender", | TransferIntervalInMinutes = 1, | LogmarkerIntervalInMinutes = 15 | }; | appender.ActivateOptions(); | | // Configure hierarchy | Hierarchy hierarchy = LogManager.GetRepository() as Hierarchy; | hierarchy.Root.AddAppender(appender); | | Or, using the helper which allows for some degree of configuration: | // 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) | LoggingHelper.InitializeFromConfiguration(ConfigurationManager.AppSettings); | `-------------------
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- C# 100.0%