FreeAndNil commented on code in PR #306:
URL: https://github.com/apache/logging-log4net/pull/306#discussion_r3792706471
##########
src/log4net/Util/SystemInfo.cs:
##########
@@ -680,20 +683,90 @@ public static bool TryParse(string s, out short val)
/// <returns>the value for the key, or <see langword="null"/></returns>
public static string? GetAppSetting(string key)
{
- if (IsAndroid)
- return Environment.GetEnvironmentVariable(key); // Android does not
support config files
+ // Android does not support config files, and neither does a runtime that
has trimmed the
+ // configuration system away.
+ if (IsAndroid || _configurationSystemUnavailable)
+ return Environment.GetEnvironmentVariable(key);
try
{
- return ConfigurationManager.AppSettings[key];
+ return ReadAppSetting(key);
}
catch (Exception e) when (!e.IsFatal())
{
- // If an exception is thrown here then it looks like the config file
does not parse correctly.
+ if (IsMissingConfigurationSystem(e))
+ {
+ // There is no configuration system to read - Native AOT trims
System.Configuration away.
+ // That is a property of the runtime rather than a fault, so it is not
reported as an
+ // error, and the environment stands in for the config file as it does
on Android.
+ _configurationSystemUnavailable = true;
Review Comment:
fixed
##########
src/log4net/Layout/PatternLayout.cs:
##########
@@ -983,14 +978,9 @@ protected virtual PatternParser CreatePatternParser(string
pattern)
PatternParser patternParser = new(pattern);
// Add all the builtin patterns
- foreach (KeyValuePair<string, Type> entry in _sGlobalRulesRegistry)
+ foreach (KeyValuePair<string, ConverterInfo> entry in
_sGlobalRulesRegistry)
{
- ConverterInfo converterInfo = new()
- {
- Name = entry.Key,
- Type = entry.Value
- };
- patternParser.PatternConverters[entry.Key] = converterInfo;
+ patternParser.PatternConverters[entry.Key] = entry.Value;
}
Review Comment:
fixed
--
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]