This is an automated email from the ASF dual-hosted git repository.

FreeAndNil pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git

commit 8bb9233846abd7605cb365f4f75b05afd385b00c
Merge: 556741f7 36aa1edc
Author: Jan Friedrich <[email protected]>
AuthorDate: Thu Aug 20 07:45:37 2026 +0200

    Recognise a native host as having no configuration system (#162)
    
    Fixes #162
    
    In a process that hosts the runtime natively there is no entry assembly for 
the
    configuration system to derive the config file path from, so reading an
    application setting fails in ClientConfigPaths with a 
PlatformNotSupportedException
    wrapped in a ConfigurationErrorsException. That matched none of the shapes
    IsMissingConfigurationSystem recognised, so log4net blamed the user's 
config file
    and repeated the report for every setting the static constructors read: 
seven
    log4net:ERROR blocks with a stack trace each, at startup, in a well 
configured
    application.
    
    A PlatformNotSupportedException anywhere in the inner exception chain is now
    treated as an absent configuration system, the same as the Native AOT case. 
A
    malformed config file cannot produce one, so unlike the 
FileNotFoundException and
    TypeLoadException cases it needs no check on which assembly it came from. 
The
    failure is logged once at debug level and application settings come from
    environment variables.
    
    Verified on Windows in a C++ host of the CoreCLR built for the purpose, in 
a host
    that loads the runtime through hostfxr, and in powershell.exe loading a
    netstandard2.0 build output: seven error blocks before, none after, and 
exactly one
    debug line with log4net.Internal.Debug on.

 .github/workflows/build.yaml                       |  16 ++
 .../162-quiet-app-settings-in-a-native-host.xml    |  15 ++
 src/log4net.Tests.Aot/NativeHostCheck.cs           | 189 +++++++++++++++++++++
 src/log4net.Tests.Aot/Program.cs                   |  10 +-
 src/log4net.Tests/Layout/PatternLayoutTest.cs      |  68 +++++++-
 src/log4net.Tests/Util/SystemInfoTest.cs           |  13 ++
 src/log4net/Util/SystemInfo.cs                     |  22 ++-
 7 files changed, 322 insertions(+), 11 deletions(-)

Reply via email to