Skip to content

Commit

Permalink
Merge branch 'zyofeng-use-connection-string' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nblumhardt committed Jun 19, 2022
2 parents db84721 + 575b344 commit 6871724
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@ public static LoggerConfiguration ApplicationInsights(
/// have already constructed AI telemetry configuration, which is extremely rare.
/// </summary>
/// <param name="loggerConfiguration">The logger configuration.</param>
/// <param name="instrumentationKey">Required Application Insights key.</param>
/// <param name="connectionString">Required Application Insights connection string.</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>
/// <param name="levelSwitch">Logging level switch for this sink</param>
/// <returns></returns>
public static LoggerConfiguration ApplicationInsights(
this LoggerSinkConfiguration loggerConfiguration,
string instrumentationKey,
string connectionString,
ITelemetryConverter telemetryConverter,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
LoggingLevelSwitch levelSwitch = null)
{
var config = TelemetryConfiguration.CreateDefault();
if (!string.IsNullOrWhiteSpace(connectionString)) config.ConnectionString = connectionString;
#pragma warning disable CS0618
var client = new TelemetryClient();
var client = new TelemetryClient(config);
#pragma warning restore CS0618

if (!string.IsNullOrWhiteSpace(instrumentationKey)) client.InstrumentationKey = instrumentationKey;

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

0 comments on commit 6871724

Please sign in to comment.