Browse Source

修复打包为单文件时日志配置文件报错的问题

pull/2833/head
MysticBoy 4 years ago
parent
commit
47392b7371
3 changed files with 17 additions and 7 deletions
  1. +1
    -1
      shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs
  2. +13
    -2
      shadowsocks-csharp/Model/NlogConfig.cs
  3. +3
    -4
      shadowsocks-csharp/Properties/PublishProfiles/FolderProfile.pubxml

+ 1
- 1
shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs View File

@@ -216,7 +216,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception e) catch (Exception e)
{ {
logger.Debug("config changed asynchrously, just ignore this server");
logger.Debug(e,"config changed asynchrously, just ignore this server");
} }
} }




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

@@ -20,8 +20,18 @@ namespace Shadowsocks.Model
Debug, Debug,
Trace, Trace,
} }
const string NLOG_CONFIG_FILE_NAME = "NLog.config";
private static string _NLOG_CONFIG_FILE_NAME=string.Empty;
public static string NLOG_CONFIG_FILE_NAME
{
get
{
if (_NLOG_CONFIG_FILE_NAME.IsNullOrEmpty())
{
_NLOG_CONFIG_FILE_NAME = Path.Combine(Environment.CurrentDirectory, "NLog.config");
}
return _NLOG_CONFIG_FILE_NAME;
}
}
const string TARGET_MIN_LEVEL_ATTRIBUTE = "minlevel"; const string TARGET_MIN_LEVEL_ATTRIBUTE = "minlevel";
const string LOGGER_FILE_NAME_ATTRIBUTE = "fileName"; const string LOGGER_FILE_NAME_ATTRIBUTE = "fileName";
@@ -108,6 +118,7 @@ namespace Shadowsocks.Model
/// </summary> /// </summary>
public static void TouchAndApplyNLogConfig() public static void TouchAndApplyNLogConfig()
{ {
if (!File.Exists(NLOG_CONFIG_FILE_NAME)) if (!File.Exists(NLOG_CONFIG_FILE_NAME))
{ {
File.WriteAllText(NLOG_CONFIG_FILE_NAME, Properties.Resources.NLog_config); File.WriteAllText(NLOG_CONFIG_FILE_NAME, Properties.Resources.NLog_config);


+ 3
- 4
shadowsocks-csharp/Properties/PublishProfiles/FolderProfile.pubxml View File

@@ -10,9 +10,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir> <PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir>
<RuntimeIdentifier>win-x86</RuntimeIdentifier> <RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>True</PublishReadyToRun>
<PublishTrimmed>True</PublishTrimmed>
<SelfContained>false</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

Loading…
Cancel
Save