Browse Source

NLogConfig - TouchAndApplyNLogConfig with Exception handler

tags/4.1.10.0
Rolf Kristensen 4 years ago
parent
commit
b1acc75796
1 changed files with 11 additions and 2 deletions
  1. +11
    -2
      shadowsocks-csharp/Model/NlogConfig.cs

+ 11
- 2
shadowsocks-csharp/Model/NlogConfig.cs View File

@@ -108,11 +108,20 @@ namespace Shadowsocks.Model
/// </summary>
public static void TouchAndApplyNLogConfig()
{
if (!File.Exists(NLOG_CONFIG_FILE_NAME))
try
{
if (File.Exists(NLOG_CONFIG_FILE_NAME))
return; // NLog.config exists, and has already been loaded
File.WriteAllText(NLOG_CONFIG_FILE_NAME, Properties.Resources.NLog_config);
LogManager.LoadConfiguration(NLOG_CONFIG_FILE_NAME);
}
catch (Exception ex)
{
NLog.Common.InternalLogger.Error(ex, "[shadowsocks] Failed to setup default NLog.config: {0}", NLOG_CONFIG_FILE_NAME);
return;
}
LoadConfiguration(); // Load the new config-file
}
/// <summary>


Loading…
Cancel
Save