Skip to content

Log on reset socket even if the logger is disabled #47620

@haludi

Description

@haludi

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If a SocketException exception is thrown while the SocketConnectionListener is accepting a new connection, the logger will still log, even if the logger is disabled

No IsEnabled check in the call position:
https://github.com/dotnet/aspnetcore/blob/release/7.0/src/Servers/Kestrel/Transport.Sockets/src/SocketConnectionListener.cs#L90
https://github.com/dotnet/aspnetcore/blob/release/6.0/src/Servers/Kestrel/Transport.Sockets/src/SocketConnectionListener.cs#L90

And explicitly skip the check on the code generation:
https://github.com/dotnet/aspnetcore/blob/release/7.0/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketsLog.cs#L50
https://github.com/dotnet/aspnetcore/blob/release/6.0/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketsTrace.cs#L70

Expected Behavior

The expected behavior is to call to IsEnabled at some point and not log if a call to it should return false

Steps To Reproduce

Implement Microsoft.Extensions.Logging.ILogger
Implement the Log method to only log without checking if should log (relay only on IsEnabled)
Define the system to use the custom logger.
Start a socket connection and reset it while the server accepts it (I didn't find how to do that).the

Exceptions (if any)

No response

.NET Version

6.0, 7.0

Anything else?

Some related PRs and issues:

#31562 (comment)

#31332
dotnet/runtime#51927
dotnet/runtime#50334

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions