-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
InternalLogger - Better support for multiple threads when using file #1927
InternalLogger - Better support for multiple threads when using file #1927
Conversation
fc926e1
to
e5210a7
Compare
Codecov Report
@@ Coverage Diff @@
## master #1927 +/- ##
========================================
Coverage ? 82%
========================================
Files ? 285
Lines ? 19545
Branches ? 2285
========================================
Hits ? 15951
Misses ? 3048
Partials ? 546 Continue to review full report at Codecov.
|
bb6a983
to
9dd455a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some questions,
also not sure about this one. The internallogger should be as simple as possible? If the internallogger won't work, it's an issue.
src/NLog/Common/InternalLogger.cs
Outdated
{ | ||
lock (LockObject) | ||
{ | ||
_writeToFileAtomicSuccesCount = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be use Interlocked.Decrement?
src/NLog/Common/InternalLogger.cs
Outdated
{ | ||
if (_writeToFileAtomicSuccesCount == 0) | ||
{ | ||
if (PlatformDetector.IsMono || !PlatformDetector.IsDesktopWin32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need this case?
9dd455a
to
4402c10
Compare
@304NotModified I have removed the support for atomic writes, and instead just implemented a lock around the file-write. Then it will at least support multi-threaded file-logging. |
Good one! |
src/NLog/Common/InternalLogger.cs
Outdated
{ | ||
lock (LockObject) | ||
// log to LogWriter | ||
var writer = LogWriter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this code in the finally
? Is this really by-design?
I only use finally
to clean up stuff, never to do functional logic. Am I missing here something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to ensure that it also tried the logger-targets in case the file-logger failed. But I have now reverted it. Not that important to me.
4402c10
to
e47d786
Compare
e47d786
to
e7271c6
Compare
Thanks for the changes. More more KISS now :) |
Extra lock-operation has been added when doing exclusive file-lock, to improve support for
multi-threaded use of the InternalLogger.
This change is