30 lines
734 B
C#
30 lines
734 B
C#
using ILogger = Serilog.ILogger;
|
|
|
|
namespace Diary.Installers
|
|
{
|
|
public class LoggingStartService : IHostedService
|
|
{
|
|
private readonly ILogger _log;
|
|
private readonly string _serviceName;
|
|
|
|
public ILogger Logger { get; }
|
|
|
|
public LoggingStartService(ILogger logger, string serviceName)
|
|
{
|
|
_log = logger.ForContext<LoggingStartService>();
|
|
_serviceName = serviceName ?? "API";
|
|
}
|
|
|
|
public Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
_log.Information("{ServiceName} service started", _serviceName);
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task StopAsync(CancellationToken cancellationToken)
|
|
{
|
|
_log.Information("{ServiceName} service stopped", _serviceName);
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
} |