Skip to content

njwilloughby/serilog-sinks-azure-analytics

 
 

Repository files navigation

Serilog.Sinks.AzureAnalytics

A Serilog sink that writes to Azure Log Analytics.

Getting started

Install Serilog.Sinks.AzureAnalytics from NuGet

Install-Package Serilog.Sinks.AzureAnalytics

Configure logger by calling WriteTo.AzureLogAnalytics(<workspaceId>, <authenticationId>)

workspaceId: Workspace Id from Azure OMS Portal connected sources.

authenticationId: Primary or Secondary key from Azure OMS Portal connected sources.

var logger = new LoggerConfiguration()
    .WriteTo.AzureLogAnalytics(<workspaceId>, <authenticationId>)
    .CreateLogger();

XML configuration

To use the AzureLogAnalytics sink with the Serilog.Settings.AppSettings package, first install that package if you haven't already done so:

Install-Package Serilog.Settings.AppSettings

In your code, call ReadFrom.AppSettings()

var logger = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .CreateLogger();

In your application's App.config or Web.config file, specify the AzureLogAnalytics sink assembly and required workspaceId and authenticationId parameters under the <appSettings>

<appSettings>
  <add key="serilog:using:AzureLogAnalytics" value="Serilog.Sinks.AzureAnalytics" />
  <add key="serilog:write-to:AzureLogAnalytics.workspaceId" value="*************" />
  <add key="serilog:write-to:AzureLogAnalytics.authenticationId" value="*************" />
 </appSettings>

Performance

Sink buffers log internally and flush to Azure Log Analytics in batches using dedicated thread for better performance.

About

Serilog sink which writes to Azure analytics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 96.0%
  • PowerShell 4.0%