Skip to content

Serilog keeps throwing ArgumentNullException #213

@shalabala

Description

@shalabala

I am using asp .net and serilog 2.10 and Microsoft.Extensions.Logging 3.1.0 but i have been able to find the source of my problem in the current sources.

My problem is that every time there is a request, an ArgumentNullExceptions appears in the project output:

Exception thrown: 'System.ArgumentNullException' in System.Collections.Concurrent.dll: 'Value cannot be null.'
Stack trace:
 >   at System.ThrowHelper.ThrowArgumentNullException(String name)

I have been able to trace back the problem to the following source files:

If here categoryName is null, and the provider is Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider, then it will end up in this line:
https://github.com/dotnet/runtime/blob/fb13c2cf6eaf69b53773e94674772f217fa39416/src/libraries/Microsoft.Extensions.Logging.Console/src/ConsoleLoggerProvider.cs#L158

Which will throw an ArgumentNullException:
https://github.com/microsoft/referencesource/blob/51cf7850defa8a17d815b4700b67116e3fa283c2/mscorlib/system/collections/Concurrent/ConcurrentDictionary.cs#L500

I dont know if im doing something wrong, but the cited piece of code seems to be not very well guarded against nulls, and this is a very criptic error message, that took me hours to track down, and i'mstill not sure, how to proceed.

Thanks for any help

Metadata

Metadata

Assignees

No one assigned

    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