Files
Cleanuparr/code/Infrastructure/Logging/LoggingInitializer.cs
Flaminel 0bd4e77e9d #31
2025-05-21 20:49:40 +03:00

33 lines
769 B
C#

using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Infrastructure.Logging;
// TODO remove
public class LoggingInitializer : BackgroundService
{
private readonly ILogger<LoggingInitializer> _logger;
public LoggingInitializer(ILogger<LoggingInitializer> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (true)
{
try
{
throw new Exception("test exception");
}
catch (Exception exception)
{
_logger.LogError(exception, "test");
}
await Task.Delay(30000, stoppingToken);
}
}
}