-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log on reset socket even if the logger is disabled #47620
Comments
The IsEnabled check is only an optimization recommended when generating the contents of the log is expensive. The ILogger itself is supposed to check if it's enabled before processing messages. The linked logs don't seem expensive to generate? |
Ok, if this behavior is by design, then the issue can be closed. |
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes. See our Issue Management Policies for more information. |
Is there an existing issue for this?
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 disabledNo
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 returnfalse
Steps To Reproduce
Implement
Microsoft.Extensions.Logging.ILogger
Implement the
Log
method to only log without checking if should log (relay only onIsEnabled
)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
The text was updated successfully, but these errors were encountered: