GeezerVison is showing github.com — Fixes from the 2026-11 audit, part 2: logging core, batches and mail by FreeAndNil · Pull Request #364 · apache/logging-log4net
Conversation
FreeAndNil
commented
Nov 16, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
#358 Fixes from the 2026-11 audit, part 2: logging core, batches and mail
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- LogLog, RendererMap and LoggingEvent's last resort use ToStringSafe
- ANT-2026-F4RWPVSV
…oes not throw
- ANT-2026-PZUYSLEY
…ails
- Per-event catch in AppenderSkeleton, AppenderAttachedImpl, MailBodies.Render
- ANT-2026-PSTH1UQ1
…forever
- StringMatchFilter.TimeoutDecision rejects undefined values
- ANT-2026-VKBDETLN
…xception{...}
- ANT-2026-O16FBEKV
- DoAppend(LoggingEvent[]) calls the array overload, as before 3.0.0
- one file lock, roll check and flush per batch
- Append(IEnumerable) overrides calling back no longer recurse
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, but nothing that is absolutely critical.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Implementation plan for #364, kept here for the record. Written up to describe the change as it stands on the branch.
Plan
Fixes from the 2026-11 audit, part 2
Context
The scan behind #355 also reported a set of lows in the logging core, the batch path, the pickup
mail and the XML layouts. This PR fixes them, grouped into four issues: #358 (application objects
that throw while being rendered), #359 (one failing event costs a whole batch; bulk overrides unused
since 3.0.0), #360 (pickup mail without MIME headers) and #361 (XML layouts read back one whitespace
character as another; the tab half follows in a later PR). Two commits close #364's own points
raised in review: NDC and MDC hidden from the editor, and an SMTP test without a timing race.
The rule behind every fix: configuration is trusted, log content and application objects are not.
A failing object costs its own text, never the record, the batch or the logging call.
Constraints that shape the design
LogLog writes exception.ToString(); it is called from the catch blocks that report rendering
failures, so a throwing ToString() there escaped them all.
NDC.PushFormat formatted with string.Format, unlike ILog.*Format, which goes through
SystemStringFormat and writes an error text.
- Since 3.0.0
DoAppend(LoggingEvent[]) passed a list and reached only Append(IEnumerable), so
the Append(LoggingEvent[]) overrides of the file appenders never ran.
- A filter loop moves on only for the three defined decisions.
- RFC 5322 limits a line to 998 octets; a pickup mail had no MIME headers at all.
- An XML parser normalises CR and CR LF to LF in element text.
Changes
- Application objects that throw while being rendered break logging #358
LogLog, the error text of a failed rendering and the last-resort exception text of
LoggingEvent fall back to the type names when ToString() throws.
- Application objects that throw while being rendered break logging #358
NDC.PushFormat formats through SystemStringFormat: a failing argument or a malformed
format string pushes the error text ILog.InfoFormat writes. A null format still throws.
- One failing event costs a whole batch; bulk overrides unused since 3.0.0 #359 Per-event catch in the base batch loop, the filter loop,
CallAppenders and
MailBodies.Render: a throwing layout, filter or appender costs its own event, reported on its
own. The mail appenders write an error text in place of an event that fails to render.
- One failing event costs a whole batch; bulk overrides unused since 3.0.0 #359 An undefined
FilterDecision counts as Neutral; StringMatchFilter.TimeoutDecision
rejects one, and from configuration it is reported and the default kept.
- Application objects that throw while being rendered break logging #358
%exception{member}: a member that throws writes an error text instead of cutting the
record.
- One failing event costs a whole batch; bulk overrides unused since 3.0.0 #359
DoAppend(LoggingEvent[]) hands the array to Append(LoggingEvent[]) again: one file lock,
roll check and flush per batch. ForwardingAppender hands each attached appender the whole batch
in turn. A re-entrancy flag keeps a subclass that overrides only one overload working.
- Pickup mail without MIME headers #360
SmtpPickupDirAppender writes MIME-Version, Content-Type: text/plain; charset=utf-8 and
Content-Transfer-Encoding: 8bit, or base64 when a line exceeds 998 octets or the layout
header or footer holds a NUL. A NUL from content is written as \0.
- XML layouts read back one whitespace character as another #361
XmlLayout and XmlLayoutSchemaLog4J write each CR and LF in message, exception text and
NDC as a character reference; text with a line break is escaped instead of written as CDATA. A
multi-line record is one physical line in the file.
- Fixes from the 2026-11 audit, part 2: logging core, batches and mail #364
NDC, MDC and their members get [EditorBrowsable(Never)] instead of the commented-out
[Obsolete]; the API reference keeps their pages.
- Fixes from the 2026-11 audit, part 2: logging core, batches and mail #364 The SMTP send deadline test waits on a signal instead of a delay.
Docs: the XML doc comments of the changed members, the pickup, XML layout and filter pages where
they describe the old behaviour. One changelog entry per change in src/changelog/3.6.1.
Sequencing
- Application objects that throw while being rendered break logging #358
LogLog first: every later catch block reports through it.
- Application objects that throw while being rendered break logging #358
NDC.PushFormat, then One failing event costs a whole batch; bulk overrides unused since 3.0.0 #359 the per-event catch and the filter decision, then Application objects that throw while being rendered break logging #358
%exception{member}.
- One failing event costs a whole batch; bulk overrides unused since 3.0.0 #359 the bulk path, after the per-event catch it builds on.
- Pickup mail without MIME headers #360 pickup headers, then XML layouts read back one whitespace character as another #361 the XML line breaks, which make an XML record one line and so
rely on the pickup body being able to carry long lines.
- Each commit: test against the unfixed code first, fix, mutate each changed line, review loop.
- Commits and pushes are the maintainer's.
Verification
dotnet build of all targets with 0 warnings, tests on net10 and, on Windows, net462.
- Each fix tested against the unfixed code first, and the changed lines mutated.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|