mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-08 02:39:29 +08:00
解决linux系统下nlog不工作的问题
This commit is contained in:
parent
267716ed39
commit
ab29a062ff
|
@ -2,7 +2,6 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using FastTunnel.Core;
|
||||
using FastTunnel.Core.Client;
|
||||
using FastTunnel.Core.Logger;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
@ -20,6 +19,7 @@ namespace FastTunnel.Client
|
|||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
LogManager.LoadConfiguration("Nlog.config");
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
try
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FastTunnel.Core.Config;
|
||||
using FastTunnel.Core.Logger;
|
||||
using FastTunnel.Core.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -20,4 +20,8 @@
|
|||
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Logger\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using FastTunnel.Core.Logger;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FastTunnel.Core.Logger
|
||||
{
|
||||
public class ConsoleLogger : ILogger
|
||||
{
|
||||
public void Error(object msg)
|
||||
{
|
||||
Console.WriteLine(string.Format("Erro - {0}", msg?.ToString()));
|
||||
}
|
||||
|
||||
public void LogDebug(string msg)
|
||||
{
|
||||
Console.WriteLine(string.Format("Debu - {0}", msg));
|
||||
}
|
||||
|
||||
public void Error(string msg)
|
||||
{
|
||||
Console.WriteLine(string.Format("Erro - {0}", msg));
|
||||
}
|
||||
|
||||
public void Info(string msg)
|
||||
{
|
||||
Console.WriteLine(string.Format("Info - {0}", msg));
|
||||
}
|
||||
|
||||
public void Warning(string msg)
|
||||
{
|
||||
Console.WriteLine(string.Format("Warn - {0}", msg));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FastTunnel.Core.Logger
|
||||
{
|
||||
public interface ILogger
|
||||
{
|
||||
void Error(object msg);
|
||||
|
||||
void Error(string msg);
|
||||
|
||||
void Warning(string msg);
|
||||
|
||||
void LogDebug(string msg);
|
||||
|
||||
void Info(string msg);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ using Newtonsoft.Json.Linq;
|
|||
using FastTunnel.Core.Config;
|
||||
using FastTunnel.Core.Exceptions;
|
||||
using FastTunnel.Core.Extensions;
|
||||
using FastTunnel.Core.Logger;
|
||||
using FastTunnel.Core.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
throwExceptions="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<targets>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using FastTunnel.Core;
|
||||
using FastTunnel.Core.Logger;
|
||||
using FastTunnel.Core.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -26,7 +25,7 @@ namespace FastTunnel.Server
|
|||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Server Start!");
|
||||
LogManager.LoadConfiguration("Nlog.config");
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
try
|
||||
|
@ -37,8 +36,8 @@ namespace FastTunnel.Server
|
|||
catch (Exception ex)
|
||||
{
|
||||
// NLog: catch any exception and log it.
|
||||
logger.Error(ex, "Stopped program because of exception");
|
||||
throw;
|
||||
logger.Error(ex);
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -10,5 +10,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir>
|
||||
<SelfContained>false</SelfContained>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<PublishSingleFile>False</PublishSingleFile>
|
||||
<PublishReadyToRun>False</PublishReadyToRun>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user