Skip to content

Commit

Permalink
Adding support for using the active TelemetryConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
DinoSourcesRex authored and Ivan Gavryliuk committed Apr 3, 2019
1 parent 81877a6 commit 87d1cde
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@ public static LoggerConfiguration ApplicationInsights(
return loggerConfiguration.Sink(new ApplicationInsightsSink(client, telemetryConverter), restrictedToMinimumLevel);
}

/// <summary>
/// Adds a Serilog sink that writes <see cref="LogEvent">log events</see> to Microsoft Application Insights
/// using the active <see cref="TelemetryConfiguration"/>
/// </summary>
/// <param name="loggerConfiguration">The logger configuration.</param>
/// <param name="telemetryConverter">Required telemetry converter.</param>
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
/// <returns></returns>
public static LoggerConfiguration ApplicationInsights(
this LoggerSinkConfiguration loggerConfiguration,
ITelemetryConverter telemetryConverter,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
{

var client = new TelemetryClient(TelemetryConfiguration.Active);

return loggerConfiguration.Sink(new ApplicationInsightsSink(client, telemetryConverter), restrictedToMinimumLevel);
}

/// <summary>
/// Adds a Serilog sink that writes <see cref="LogEvent">log events</see> to Microsoft Application Insights
/// using a custom <see cref="ITelemetry"/> converter / constructor.
Expand Down

0 comments on commit 87d1cde

Please sign in to comment.