mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Load NLog.config when not in AppContext.BaseDirectory instead
This is needed as custom NLog.config no longer gets loaded in single-file scenario, where NLog probes the directory of the unpacked files instead. For non-single-publishes this doesn't change anything, as home directory is equal to base directory if not using custom path.
This commit is contained in:
@@ -753,8 +753,8 @@ namespace ArchiSteamFarm {
|
||||
case "":
|
||||
// No directory, root folder
|
||||
switch (fileName) {
|
||||
case Logging.NLogConfigurationFile:
|
||||
case SharedInfo.LogFile:
|
||||
case "NLog.config":
|
||||
// Files with those names in root directory we want to keep
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ using NLog.Targets;
|
||||
|
||||
namespace ArchiSteamFarm.NLog {
|
||||
internal static class Logging {
|
||||
internal const string NLogConfigurationFile = "NLog.config";
|
||||
|
||||
private const byte ConsoleResponsivenessDelay = 250; // In miliseconds
|
||||
private const string GeneralLayout = @"${date:format=yyyy-MM-dd HH\:mm\:ss}|${processname}-${processid}|${level:uppercase=true}|" + LayoutMessage;
|
||||
private const string LayoutMessage = @"${logger}|${message}${onexception:inner= ${exception:format=toString,Data}}";
|
||||
@@ -142,8 +144,8 @@ namespace ArchiSteamFarm.NLog {
|
||||
|
||||
internal static void InitCoreLoggers(bool uniqueInstance) {
|
||||
try {
|
||||
if ((Directory.GetCurrentDirectory() != SharedInfo.HomeDirectory) && File.Exists("NLog.config")) {
|
||||
LogManager.Configuration = new XmlLoggingConfiguration("NLog.config");
|
||||
if ((Directory.GetCurrentDirectory() != AppContext.BaseDirectory) && File.Exists(NLogConfigurationFile)) {
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(NLogConfigurationFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ASF.ArchiLogger.LogGenericException(e);
|
||||
|
||||
Reference in New Issue
Block a user