提交Log
This commit is contained in:
parent
c448afdd1d
commit
71509a6d43
28
Core/JXCMS.Core/Log/Log.cs
Normal file
28
Core/JXCMS.Core/Log/Log.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System.IO;
|
||||||
|
using JXCMS.Core.Utils;
|
||||||
|
using Serilog;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
namespace JXCMS.Core.Log
|
||||||
|
{
|
||||||
|
public class Log
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(@"Logs"))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(@"Logs");
|
||||||
|
}
|
||||||
|
Serilog.Log.Logger = new LoggerConfiguration()
|
||||||
|
.ReadFrom.Configuration(ConfigHelper.Configs)
|
||||||
|
.WriteTo.Console()
|
||||||
|
.WriteTo.Logger(l => l.Filter.ByIncludingOnly(e => e.Level == LogEventLevel.Information && !e.Properties.ContainsKey("name")).WriteTo.RollingFile(@"Logs\Info-{Date}.log"))
|
||||||
|
.WriteTo.Logger(l => l.Filter.ByIncludingOnly(e => e.Level == LogEventLevel.Debug && !e.Properties.ContainsKey("name") ).WriteTo.RollingFile(@"Logs\Debug-{Date}.log"))
|
||||||
|
.WriteTo.Logger(l => l.Filter.ByIncludingOnly(e => e.Level == LogEventLevel.Warning && !e.Properties.ContainsKey("name") ).WriteTo.RollingFile(@"Logs\Warning-{Date}.log"))
|
||||||
|
.WriteTo.Logger(l => l.Filter.ByIncludingOnly(e => e.Level == LogEventLevel.Error && !e.Properties.ContainsKey("name") ).WriteTo.RollingFile(@"Logs\Error-{Date}.log"))
|
||||||
|
.WriteTo.Logger(l => l.Filter.ByIncludingOnly(e => e.Level == LogEventLevel.Fatal && !e.Properties.ContainsKey("name") ).WriteTo.RollingFile(@"Logs\Fatal-{Date}.log"))
|
||||||
|
.WriteTo.Logger(l => l.Filter.ByIncludingOnly(e => e.Properties.ContainsKey("name") ).WriteTo.RollingFile(@"Logs\Spider-{Date}.log"))
|
||||||
|
.CreateLogger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user