|
|
@ -483,11 +483,13 @@ public sealed class App : Application |
|
|
|
|
|
|
|
|
|
|
|
private static LoggingConfiguration ConfigureLogging() |
|
|
|
private static LoggingConfiguration ConfigureLogging() |
|
|
|
{ |
|
|
|
{ |
|
|
|
var logConfig = new LoggingConfiguration(); |
|
|
|
LogManager.Setup().LoadConfiguration(builder => { |
|
|
|
|
|
|
|
var debugTarget = builder.ForTarget("console").WriteTo(new DebuggerTarget |
|
|
|
// File target |
|
|
|
{ |
|
|
|
logConfig.AddRule(NLog.LogLevel.Debug, NLog.LogLevel.Fatal, |
|
|
|
Layout = "${message}" |
|
|
|
new FileTarget("logfile") |
|
|
|
}).WithAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileTarget = builder.ForTarget("logfile").WriteTo(new FileTarget |
|
|
|
{ |
|
|
|
{ |
|
|
|
Layout = "${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}", |
|
|
|
Layout = "${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}", |
|
|
|
ArchiveOldFileOnStartup = true, |
|
|
|
ArchiveOldFileOnStartup = true, |
|
|
@ -495,19 +497,21 @@ public sealed class App : Application |
|
|
|
ArchiveFileName = "${specialfolder:folder=ApplicationData}/StabilityMatrix/app.{#}.log", |
|
|
|
ArchiveFileName = "${specialfolder:folder=ApplicationData}/StabilityMatrix/app.{#}.log", |
|
|
|
ArchiveNumbering = ArchiveNumberingMode.Rolling, |
|
|
|
ArchiveNumbering = ArchiveNumberingMode.Rolling, |
|
|
|
MaxArchiveFiles = 2 |
|
|
|
MaxArchiveFiles = 2 |
|
|
|
}); |
|
|
|
}).WithAsync(); |
|
|
|
|
|
|
|
|
|
|
|
// Debugger Target |
|
|
|
// Filter some sources to be warn levels or above only |
|
|
|
logConfig.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, |
|
|
|
builder.ForLogger("System.*").WriteToNil(NLog.LogLevel.Warn); |
|
|
|
new DebuggerTarget("debugger") |
|
|
|
builder.ForLogger("Microsoft.*").WriteToNil(NLog.LogLevel.Warn); |
|
|
|
{ |
|
|
|
builder.ForLogger("Microsoft.Extensions.Http.*").WriteToNil(NLog.LogLevel.Warn); |
|
|
|
Layout = "${message}" |
|
|
|
|
|
|
|
}); |
|
|
|
builder.ForLogger().FilterMinLevel(NLog.LogLevel.Trace).WriteTo(debugTarget); |
|
|
|
|
|
|
|
builder.ForLogger().FilterMinLevel(NLog.LogLevel.Debug).WriteTo(fileTarget); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Sentry |
|
|
|
// Sentry |
|
|
|
if (SentrySdk.IsEnabled) |
|
|
|
if (SentrySdk.IsEnabled) |
|
|
|
{ |
|
|
|
{ |
|
|
|
logConfig.AddSentry(o => |
|
|
|
LogManager.Configuration.AddSentry(o => |
|
|
|
{ |
|
|
|
{ |
|
|
|
o.InitializeSdk = false; |
|
|
|
o.InitializeSdk = false; |
|
|
|
o.Layout = "${message}"; |
|
|
|
o.Layout = "${message}"; |
|
|
@ -521,9 +525,6 @@ public sealed class App : Application |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LogManager.Configuration = logConfig; |
|
|
|
return LogManager.Configuration; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return logConfig; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|