Browse Source

Merge pull request #2846 from snakefoot/master

NLogConfig - TouchAndApplyNLogConfig with Exception handler
tags/4.1.10.0
Allen Zhu GitHub 4 years ago
parent
commit
67679167da
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
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> /// </summary>
public static void TouchAndApplyNLogConfig() 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); 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> /// <summary>


Loading…
Cancel
Save