Microsoft.ApplicationInsights.AspNetCore.Logging.ApplicationInsightsLogger.GetSeverityLevel(Microsoft.Extensions.Logging.LogLevel)

Here are the examples of the csharp api class Microsoft.ApplicationInsights.AspNetCore.Logging.ApplicationInsightsLogger.GetSeverityLevel(Microsoft.Extensions.Logging.LogLevel) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: ApplicationInsights-aspnetcore
Source File: ApplicationInsightsLogger.cs
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
        {
            if (this.IsEnabled(logLevel))
            {
                var stateDictionary = state as IReadOnlyList<KeyValuePair<string, object>>;
                if (exception == null)
                {
                    var traceTelemetry = new TraceTelemetry(formatter(state, exception), this.GetSeverityLevel(logLevel));
                    PopulateTelemetry(traceTelemetry, stateDictionary);
                    this.telemetryClient.TrackTrace(traceTelemetry);
                }
                else
                {
                    var exceptionTelemetry = new ExceptionTelemetry(exception);
                    exceptionTelemetry.Message = formatter(state, exception);
                    exceptionTelemetry.SeverityLevel = this.GetSeverityLevel(logLevel);
                    exceptionTelemetry.Context.Properties["Exception"] = exception.ToString();
                    PopulateTelemetry(exceptionTelemetry, stateDictionary);
                    this.telemetryClient.TrackException(exceptionTelemetry);
                }
            }
        }