有没有办法关闭 Hangfire 对 serilog 所做的日志记录?我们正在使用我们自己的抽象,我不希望在使用 serilog 时来自 Hangfire 记录器的所有这些额外噪音。
// INIT call under web project
namespace MYApp.Web.App_Start
{
public static class Bootstrapper
{
public static void Run()
{
Core.Logging.Serilog.SetConfiguration();
}
}
}
// 设置配置方法的项目
namespace MYApp.Core.Logging
{
public static class Serilog
{
public static void SetConfiguration()
{
Log.Logger = new LoggerConfiguration()
//.WriteTo.File(@"c:\log-.txt", rollingInterval: RollingInterval.Minute, shared: true)
.WriteTo.Email(new EmailConnectionInfo()
{
FromEmail = "xxxxxx@gmail.com",
MailServer = "smtp.gmail.com",
ToEmail = "xxxx@xxxx.xx.xx",
NetworkCredentials = new NetworkCredential("xxxx@gmail.com", "xxxxxxxxx"),
Port = 587,
EnableSsl = true,
EmailSubject = "YYYYYY: Error Log"
}, outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {NewLine} {Message:lj}{NewLine}{Exception}")
.Filter.ByExcluding(Matching.FromSource("Hangfire"))
.CreateLogger();
}
}
}
斯蒂芬大帝
慕标琳琳
慕森卡
相关分类