mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-01-16 01:38:02 -05:00
33 lines
769 B
C#
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);
|
|
}
|
|
}
|
|
}
|