diff --git a/FastTunnel.Api/FastTunnel.Api.csproj b/FastTunnel.Api/FastTunnel.Api.csproj index 8332ed2..d598b3d 100644 --- a/FastTunnel.Api/FastTunnel.Api.csproj +++ b/FastTunnel.Api/FastTunnel.Api.csproj @@ -1,6 +1,6 @@ - net6.0 + net5.0;net6.0 1.1.0 https://github.com/FastTunnel/FastTunnel/tree/v2/FastTunnel.Api https://github.com/FastTunnel/FastTunnel/tree/v2/FastTunnel.Api @@ -9,8 +9,8 @@ - - + + diff --git a/FastTunnel.Client/FastTunnel.Client.csproj b/FastTunnel.Client/FastTunnel.Client.csproj index d4c55c0..d05c4df 100644 --- a/FastTunnel.Client/FastTunnel.Client.csproj +++ b/FastTunnel.Client/FastTunnel.Client.csproj @@ -6,7 +6,9 @@ - + + + @@ -20,9 +22,6 @@ Always - - Always - Always diff --git a/FastTunnel.Client/Program.cs b/FastTunnel.Client/Program.cs index fdce01e..e78307e 100644 --- a/FastTunnel.Client/Program.cs +++ b/FastTunnel.Client/Program.cs @@ -10,6 +10,7 @@ using System; using Microsoft.AspNetCore.Builder; using FastTunnel.Core; using Microsoft.Extensions.Configuration; +using Serilog; namespace FastTunnel.Client; @@ -29,21 +30,20 @@ class Program public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .UseSerilog((hostBuilderContext, services, loggerConfiguration) => + { + var enableFileLog = (bool)(hostBuilderContext.Configuration.GetSection("EnableFileLog")?.Get(typeof(bool)) ?? false); + loggerConfiguration.WriteTo.Console(); + if (enableFileLog) + { + loggerConfiguration.WriteTo.File("Logs/log.txt", rollingInterval: RollingInterval.Day, retainedFileCountLimit: 7); + } + }) .UseWindowsService() .ConfigureServices((hostContext, services) => { - // -------------------FastTunnel START------------------ - services.AddFastTunnelClient(hostContext.Configuration.GetSection("ClientSettings")); - // -------------------FastTunnel EDN-------------------- - }) - .ConfigureLogging((HostBuilderContext context, ILoggingBuilder logging) => - { - var enableFileLog = (bool)(context.Configuration.GetSection("EnableFileLog")?.Get(typeof(bool)) ?? false); - if (enableFileLog) - { - logging.ClearProviders(); - logging.SetMinimumLevel(LogLevel.Trace); - logging.AddLog4Net(); - } + // -------------------FastTunnel START------------------ + services.AddFastTunnelClient(hostContext.Configuration.GetSection("ClientSettings")); + // -------------------FastTunnel EDN-------------------- }); } diff --git a/FastTunnel.Client/appsettings.json b/FastTunnel.Client/appsettings.json index 69310b2..149f728 100644 --- a/FastTunnel.Client/appsettings.json +++ b/FastTunnel.Client/appsettings.json @@ -1,4 +1,4 @@ -{ +{ "Logging": { "LogLevel": { // Trace Debug Information Warning Error @@ -8,7 +8,7 @@ } }, // 是否启用文件日志输出 - "EnableFileLog": false, + "EnableFileLog": true, "ClientSettings": { "Server": { // [必选] 服务端ip/域名(来自服务端配置文件的urls参数) @@ -61,4 +61,4 @@ } ] } -} \ No newline at end of file +} diff --git a/FastTunnel.Client/log4net.config b/FastTunnel.Client/log4net.config deleted file mode 100644 index 86e9d65..0000000 --- a/FastTunnel.Client/log4net.config +++ /dev/null @@ -1,72 +0,0 @@ - - - - - Value of priority may be ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FastTunnel.Core/FastTunnel.Core.csproj b/FastTunnel.Core/FastTunnel.Core.csproj index bd3f2bf..f26b847 100644 --- a/FastTunnel.Core/FastTunnel.Core.csproj +++ b/FastTunnel.Core/FastTunnel.Core.csproj @@ -1,7 +1,7 @@ - net6.0 + net5.0;net6.0 2.1.0 https://github.com/SpringHgui/FastTunnel MIT @@ -20,8 +20,8 @@ - - + + diff --git a/FastTunnel.Server/FastTunnel.Server.csproj b/FastTunnel.Server/FastTunnel.Server.csproj index 4b081a7..9452eb2 100644 --- a/FastTunnel.Server/FastTunnel.Server.csproj +++ b/FastTunnel.Server/FastTunnel.Server.csproj @@ -1,46 +1,45 @@ - - DEBUG - enable - + + DEBUG + enable + - - net6.0 - false - + + net6.0 + false + - - - - - - + + + + + + - - - - - - - - + + + + + + + - - - - - - - - + + + + + + + + - - - Always - - - Always - - + + + Always + + + Always + + diff --git a/FastTunnel.Server/Program.cs b/FastTunnel.Server/Program.cs index 0a8e82a..307c6c2 100644 --- a/FastTunnel.Server/Program.cs +++ b/FastTunnel.Server/Program.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Serilog; namespace FastTunnel.Server; @@ -20,6 +21,15 @@ public class Program public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) + .UseSerilog((hostBuilderContext, services, loggerConfiguration) => + { + var enableFileLog = (bool)(hostBuilderContext.Configuration.GetSection("EnableFileLog")?.Get(typeof(bool)) ?? false); + loggerConfiguration.WriteTo.Console(); + if (enableFileLog) + { + loggerConfiguration.WriteTo.File("Logs/log.txt", rollingInterval: RollingInterval.Day, retainedFileCountLimit: 7); + } + }) .UseWindowsService() .ConfigureWebHost(webHostBuilder => { @@ -33,15 +43,5 @@ public class Program .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); - }) - .ConfigureLogging((HostBuilderContext context, ILoggingBuilder logging) => - { - var enableFileLog = (bool)context.Configuration.GetSection("EnableFileLog").Get(typeof(bool)); - if (enableFileLog) - { - logging.ClearProviders(); - logging.SetMinimumLevel(LogLevel.Trace); - logging.AddLog4Net(); - } }); } diff --git a/FastTunnel.Server/log4net.config b/FastTunnel.Server/log4net.config deleted file mode 100644 index 86e9d65..0000000 --- a/FastTunnel.Server/log4net.config +++ /dev/null @@ -1,72 +0,0 @@ - - - - - Value of priority may be ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -