public void Log <TState>( LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter ) { SeverityLevel severityLevel = SeverityLevel.Verbose; var msg = formatter(state, exception); var properties = GetProperties(state); switch (logLevel) { case LogLevel.Trace: case LogLevel.Debug: severityLevel = SeverityLevel.Verbose; break; case LogLevel.Information: severityLevel = SeverityLevel.Information; break; case LogLevel.Warning: severityLevel = SeverityLevel.Warning; break; case LogLevel.Error: severityLevel = SeverityLevel.Error; break; case LogLevel.Critical: case LogLevel.None: severityLevel = SeverityLevel.Critical; break; } if (exception != null) { ApplicationInsights.TrackException(new Error() { Name = exception.GetType().Name, Message = exception.ToString() }, null, severityLevel, properties); } else { ApplicationInsights.TrackTrace(msg, severityLevel, properties); } }