Skip to content

TheMirzai/log4net.Azure

 
 

Repository files navigation

log4net.Appenders.Azure

Transfer all your logs to the Azure Table or Blob Storage via Appender for log4Net, and customise the format of logs

Install

Add To project via NuGet:

  1. Right click on a project and click 'Manage NuGet Packages'.
  2. Search for 'log4net.Appenders.Azure' and click 'Install'.

Configuration

Table Storage

Every log entry is stored in a separate row.

<appender name="AzureTableAppender" type="log4net.Appender.AzureTableAppender, log4net.Appender.Azure">
   <param name="TableName" value="testLoggingTable"/>
   <!-- You can either specify a connection string or use the ConnectionStringName property instead -->
   <param name="ConnectionString" value="UseDevelopmentStorage=true"/>
   <!--<param name="ConnectionStringName" value="GlobalConfigurationString" />-->
   <!-- You can specify this to make each LogProperty as separate Column in TableStorage, 
	Default: all Custom Properties were logged into one single field -->
   <param name="PropAsColumn" value="true" />
   <param name="PartitionKeyType" value="LoggerName" />
 </appender>
  • TableName:
    Name of the table in Table Storage
  • ConnectionString:
    The full Azure Storage connection string
  • ConnectionStringName:
    Name of a connection string specified under connectionString
  • PropAsColumn:
    Optional
    Default: all properties were written in a single field(default).
    If you specifiy this with the value true then each custom log4net property is logged as separate column/field in the table.
    Remember that Table storage has a Limit of 255 Properties (see here).
  • PartitionKeyType:
    Optional
    Default "LoggerName": (each logger gets his own partition in Table Storage)
    "DateReverse": order by Date Reverse to see the latest items first (How to order elements by date reverse)

BlobStorage

Every log Entry can be stored as a seperate XML, JSON or TXT file.

<appender name="AzureBlobAppender" type="log4net.Appender.AzureBlobAppender, log4net.Appender.Azure">
  <param name="ContainerName" value="testloggingblob"/>
  <param name="DirectoryName" value="logs"/>
  <param name="FileFormat" value="xml"/>
  <param name="DocumentName" value="logs"/>
  <!-- You can either specify a connection string or use the ConnectionStringName property instead -->
  <param name="ConnectionString" value="UseDevelopmentStorage=true"/>
  <!--<param name="ConnectionStringName" value="GlobalConfigurationString" />-->
</appender>
  • ContainerName:
    Name of the container in Blob Storage
  • DirectoryName:
    Name of the folder in the specified container
  • FileFormat:
    Optional
    Default: XML
    The format of the generated log file, can be either xml, txt or json
  • DocumentName:
    Optional
    Default: 'entry.log'
    The name of the generated log file. String format is {DateTime}.{DocumentName}.{FileFormat}
  • ConnectionString:
    The full Azure Storage connection string
  • ConnectionStringName:
    Name of a connection string specified under connectionString

AppendBlobStorage

Every log Entry can be stored as a seperate XML, JSON or TXT file.

<appender name="AzureAppendBlobAppender" type="log4net.Appender.AzureAppendBlobAppender, log4net.Appender.Azure">
  <param name="ContainerName" value="testloggingblob"/>
  <param name="DirectoryName" value="logs"/>
  <param name="FileFormat" value="json"/>
  <param name="DocumentName" value="logs"/>
  <!-- You can either specify a connection string or use the ConnectionStringName property instead -->
  <param name="ConnectionString" value="UseDevelopmentStorage=true"/>
  <!--<param name="ConnectionStringName" value="GlobalConfigurationString" />-->
</appender>
  • ContainerName:
    Name of the container in Blob Storage
  • DirectoryName:
    Name of the folder in the specified container
  • FileFormat:
    Optional
    Default: XML
    The format of the generated log file, can be either xml, txt or json
  • DocumentName:
    Optional
    Default: 'entry.log'
    The name of the generated log file. String format is {DateTime}.{DocumentName}.{FileFormat}
  • ConnectionString:
    The full Azure Storage connection string
  • ConnectionStringName:
    Name of a connection string specified under connectionString

Formats

Currently XML, JSON and TXT output formats are supported

Author

Matthew Mirzai (https://github.com/TheMirzai)

Credits

Karell Ste-Marie (https://github.com/stemarie) Creator of the original package, which is no longer active.

About

log4net.Azure

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%