Skip to content

Commit 888aa19

Browse files
committed
fix logging null reference
1 parent 712bb96 commit 888aa19

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLogger.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ internal sealed class PowertoolsLogger : ILogger
4040
/// The name
4141
/// </summary>
4242
private readonly string _name;
43+
44+
/// <summary>
45+
/// The current configuration
46+
/// </summary>
47+
private LoggerConfiguration _currentConfig;
4348

4449
/// <summary>
4550
/// The Powertools for AWS Lambda (.NET) configurations
@@ -77,7 +82,7 @@ public PowertoolsLogger(
7782
powertoolsConfigurations, systemWrapper, getCurrentConfig);
7883

7984
_powertoolsConfigurations.SetExecutionEnvironment(this);
80-
CurrentConfig = GetCurrentConfig();
85+
_currentConfig = GetCurrentConfig();
8186

8287
if (_lambdaLogLevelEnabled && _logLevel < _lambdaLogLevel)
8388
{
@@ -87,7 +92,7 @@ public PowertoolsLogger(
8792
}
8893
}
8994

90-
private LoggerConfiguration CurrentConfig { get; set; }
95+
private LoggerConfiguration CurrentConfig => _currentConfig ??= GetCurrentConfig();
9196

9297
/// <summary>
9398
/// Sets the minimum level.
@@ -370,7 +375,7 @@ private object GetFormattedLogEntry(LogLevel logLevel, DateTime timestamp, objec
370375
/// </summary>
371376
internal void ClearConfig()
372377
{
373-
CurrentConfig = null;
378+
_currentConfig = null;
374379
}
375380

376381
/// <summary>

0 commit comments

Comments
 (0)