36 lines
1002 B
C#
36 lines
1002 B
C#
using Serilog.Context;
|
|
|
|
namespace MarcoBMS.Services.Service
|
|
{
|
|
public class LoggingService : ILoggingService
|
|
{
|
|
private readonly ILogger<LoggingService> _logger;
|
|
|
|
public LoggingService(ILogger<LoggingService> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public void LogError(Exception? ex, string? message, params object[]? args)
|
|
{
|
|
using (LogContext.PushProperty("Error", ex))
|
|
using (LogContext.PushProperty("LogLevel", "Error"))
|
|
_logger.LogError(message, args);
|
|
}
|
|
|
|
public void LogInfo(string? message, params object[]? args)
|
|
{
|
|
using (LogContext.PushProperty("LogLevel", "Information"))
|
|
_logger.LogInformation(message, args);
|
|
}
|
|
|
|
public void LogWarning(string? message, params object[]? args)
|
|
{
|
|
using (LogContext.PushProperty("LogLevel", "Warning"))
|
|
_logger.LogWarning(message,args);
|
|
}
|
|
}
|
|
|
|
}
|
|
|