FreeAndNil commented on PR #364:
URL: https://github.com/apache/logging-log4net/pull/364#issuecomment-7048061838
Implementation plan for #364, kept here for the record. Written up to
describe the change as it stands on the branch.
<details>
<summary>Plan</summary>
# 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
1. #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.
2. #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.
3. #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.
4. #359 An undefined `FilterDecision` counts as `Neutral`;
`StringMatchFilter.TimeoutDecision`
rejects one, and from configuration it is reported and the default kept.
5. #358 `%exception{member}`: a member that throws writes an error text
instead of cutting the
record.
6. #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.
7. #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`.
8. #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.
9. #364 `NDC`, `MDC` and their members get `[EditorBrowsable(Never)]`
instead of the commented-out
`[Obsolete]`; the API reference keeps their pages.
10. #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
1. #358 `LogLog` first: every later catch block reports through it.
2. #358 `NDC.PushFormat`, then #359 the per-event catch and the filter
decision, then #358
`%exception{member}`.
3. #359 the bulk path, after the per-event catch it builds on.
4. #360 pickup headers, then #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.
5. Each commit: test against the unfixed code first, fix, mutate each
changed line, review loop.
6. 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.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]