This commit is contained in:
Kevin Kai Berthold 2025-12-03 18:19:06 +01:00
parent 7b147569e0
commit d32207fbf7
6 changed files with 30 additions and 51 deletions

View file

@ -30,7 +30,8 @@ public class SmtpServer<TSession>(IServiceScopeFactory scopeFactory, ILogger<Smt
IsRunning = true;
// log
_logger.LogInformation("SMTP listening on {HOST}:{PORT}", config.Host, config.Port);
if (_logger.IsEnabled(LogLevel.Information))
_logger.LogInformation("SMTP listening on {HOST}:{PORT}", config.Host, config.Port);
// handler loop
while (!cancellationToken.IsCancellationRequested)
@ -46,7 +47,8 @@ public class SmtpServer<TSession>(IServiceScopeFactory scopeFactory, ILogger<Smt
catch (OperationCanceledException) { }
catch (Exception ex)
{
_logger.LogError(ex.ToString());
if (_logger.IsEnabled(LogLevel.Error))
_logger.LogError("ERROR: [{ERR}]", ex.ToString());
}
}