mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 22:20:52 +00:00
Fix HistoryTarget when using custom NLog configuration
This commit is contained in:
@@ -80,20 +80,31 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal static void InitHistoryLogger() {
|
||||
if (IsUsingCustomConfiguration || (LogManager.Configuration == null)) {
|
||||
if (LogManager.Configuration == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: We could use some nice HTML layout for this
|
||||
HistoryTarget historyTarget = new HistoryTarget("History") {
|
||||
Layout = GeneralLayout,
|
||||
MaxCount = 20
|
||||
};
|
||||
HistoryTarget historyTarget;
|
||||
|
||||
LogManager.Configuration.AddTarget(historyTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, historyTarget));
|
||||
if (IsUsingCustomConfiguration) {
|
||||
historyTarget = LogManager.Configuration.AllTargets.OfType<HistoryTarget>().FirstOrDefault();
|
||||
|
||||
if (historyTarget == null) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// TODO: We could use some nice HTML layout for this
|
||||
historyTarget = new HistoryTarget("History") {
|
||||
Layout = GeneralLayout,
|
||||
MaxCount = 20
|
||||
};
|
||||
|
||||
LogManager.Configuration.AddTarget(historyTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, historyTarget));
|
||||
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
|
||||
LogManager.ReconfigExistingLoggers();
|
||||
IPC.OnNewHistoryTarget(historyTarget);
|
||||
}
|
||||
|
||||
@@ -163,4 +174,4 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user