Add FileAppend feature to the Logging module - #1
Conversation
…rms with the work the other libraries are actually charged for The log4net arms of two existing features were doing strictly more work than their counterparts, so the measurements were not comparing like with like. `Log4NetFixture` now sets `Fix = FixFlags.Partial` on the `BufferingForwardingAppender`. log4net defaults to `FixFlags.All`, which captures caller location (a stack walk) and the Windows identity (a local security authority lookup) for every buffered event. The counterparts in this feature - NLog's `AsyncTargetWrapper` and Serilog's `WriteTo.Async` - capture neither. Measured in isolation on one machine, the two flags cost +6.9 us and +81.6 us per event respectively, against ~325 ns for everything `Partial` fixes; the flag choice, not the buffering pipeline, was almost the whole result. `Partial` is the set log4net's own `FixFlags` documentation recommends for performance and still fixes everything te, level, exception and properties. `03_StructuredProperties` now uses `ThreadContext` instead of `LogicalThreadContext`. The other arms of th parameters straight to the logger and use no ambient context at all, so the async-flow-safe variant charged log4net for for. `05_ScopeOrContext` is where async-safe context belongs and deliberately keeps `LogicalThreadContext`, matching Serilog's ` The new `FileAppend` feature covers the gap e touches a file. Each arm appends one event to an already open handle with buffering enabled and no flush per event, tht layout, and delivery is validated by reading the file back off disk rather than from an in-memory sink. log4net, NLog, rted; Microsoft.Extensions.Logging is `Unsupported` because the core package defines no file provider.
|
@FreeAndNil thanks for the PR and especially for the detailed explanation! The The main issue was the measurement boundary: log4net, NLog, and Serilog formatted synchronously, while ZLogger only queued the event for background processing. Filesystem and OS caching also added noise without measuring an actual flush. I preserved your commit and merged the PR, then locally replaced Full validation and the smoke run of all 38 logging benchmarks pass. Thanks again — your fairness fixes remain and provided a great foundation for the new scenario. |
|
@NikolayPianikov Thanks. |
|
The changes are already in version 1.0.2 |
align the log4net arms with the work the other libraries are actually charged for
The log4net arms of two existing features were doing strictly more work than
their counterparts, so the measurements were not comparing like with like.
Log4NetFixturenow setsFix = FixFlags.Partialon theBufferingForwardingAppender. log4net defaults toFixFlags.All, whichcaptures caller location (a stack walk) and the Windows identity (a local
security authority lookup) for every buffered event. The counterparts in this
feature - NLog's
AsyncTargetWrapperand Serilog'sWriteTo.Async- captureneither. Measured in isolation on one machine, the two flags cost +6.9 us and
+81.6 us per event respectively, against ~325 ns for everything
Partialfixes; the flag choice, not the buffering pipeline, was almost the whole
result.
Partialis the set log4net's ownFixFlagsdocumentation recommendsfor performance and still fixes everything this feature validates: message,
level, exception and properties.
03_StructuredPropertiesnow usesThreadContextinstead ofLogicalThreadContext. The other arms of that feature pass structuredparameters straight to the logger and use no ambient context at all, so the
async-flow-safe variant charged log4net for propagation nobody else paid for.
05_ScopeOrContextis where async-safe context belongs and deliberately keepsLogicalThreadContext, matching Serilog'sLogContext.The new
FileAppendfeature covers the gap that no scenario in the moduletouches a file. Each arm appends one event to an already open handle with
buffering enabled and no flush per event, through an equivalent plain-text
layout, and delivery is validated by reading the file back off disk rather
than from an in-memory sink. log4net, NLog, Serilog and ZLogger are supported;
Microsoft.Extensions.Logging is
Unsupportedbecause the core package definesno file provider.