FreeAndNil opened a new issue, #358:
URL: https://github.com/apache/logging-log4net/issues/358
log4net promises that a logging call never throws and that an event is
written whole. Three places
break that when application code throws while log4net renders it:
- `LogLog.Debug`, `Warn` and `Error` call `exception.ToString()` without a
guard. If an exception's
own `ToString()` throws again (for example an
`ArgumentOutOfRangeException` that names an object
whose `ToString()` threw it), every catch block meant to shield the caller
reports through
`LogLog` and throws again, so `log.InfoFormat(...)` throws into the
application. The appenders
after the failing one are skipped for that event. Reachable with default
settings since 3.4.0,
where `OnlyOnceErrorHandler` reports every first error through `LogLog`.
ANT-2026-F4RWPVSV.
- `NDC.PushFormat` formats with a bare `string.Format`. An argument that
fails to format throws into
the application, no frame is pushed and the `using` body is skipped.
`ILog.*Format` absorbs the
same arguments. ANT-2026-PZUYSLEY.
- `%exception{message}`, `{source}`, `{stacktrace}`, `{targetsite}` and
`{helplink}` read the
exception's members unguarded. A member that throws cuts the record
without a line end, and the
next record follows on the same line. ANT-2026-O16FBEKV.
Each needs an application type that fails this way; logged text alone cannot
cause it.
Proposed fix: render the exception for `LogLog` inside a `try`, falling back
to the type names; the
same helper covers the last-resort exception rendering in
`LoggingEvent.GetExceptionString`. Format
`NDC.PushFormat` the way `ILog.*Format` does, so a failing argument gives
the `<log4net.Error>`
marker; a null format still throws `ArgumentNullException`. Read the
`%exception` member inside a
`try` and write a `<log4net.Error>` marker when it throws.
--
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]