Skip to content

Commit

Permalink
Merge pull request #2846 from snakefoot/master
Browse files Browse the repository at this point in the history
NLogConfig - TouchAndApplyNLogConfig with Exception handler
  • Loading branch information
celeron533 authored Apr 9, 2020
2 parents 23ce58a + b1acc75 commit 6767916
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions shadowsocks-csharp/Model/NlogConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,20 @@ private static XmlNode SelectSingleNode(XmlDocument doc, string xpath)
/// </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>
Expand Down

0 comments on commit 6767916

Please sign in to comment.