Sitelet https://github.com/microsoft/ApplicationInsights-dotnet/issues/1436
Skip to content

NullReferenceException in ApplicationInsightsLogger.Log when exception contains a Data entry with a null value #1436

Description

If you are reporting bug/issue, please provide detailed Repro instructions.

Repro Steps

var exception = new System.Exception();
exception.Data["foo"] = null;
throw exception;

Actual Behavior

Response exception in middleware: System.AggregateException: An error occurred while writing to logger(s). (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.ApplicationInsights.AspNetCore.Logging.ApplicationInsightsLogger.<>c__DisplayClass9_01.<Log>b__0(DictionaryEntry item) at System.Collections.Generic.List1.ForEach(Action1 action) at Microsoft.ApplicationInsights.AspNetCore.Logging.ApplicationInsightsLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter) at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter) --- End of inner exception stack trace --- at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter) at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args) at Microsoft.Extensions.Logging.LoggerExtensions.LogError(ILogger logger, EventId eventId, Exception exception, String message, Object[] args)

Expected Behavior

Logs an exception

Version Info

SDK Version : 2.5.1
.NET Version : .NET core 2.2
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) :
OS : Windows
Hosting Info (IIS/Azure WebApps/ etc) :

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions