diff --git a/SlnMesnac.Serilog/SerilogExtensions.cs b/SlnMesnac.Serilog/SerilogExtensions.cs index 6f9b303..f9e5128 100644 --- a/SlnMesnac.Serilog/SerilogExtensions.cs +++ b/SlnMesnac.Serilog/SerilogExtensions.cs @@ -37,12 +37,16 @@ namespace SlnMesnac.Serilog { public static IApplicationBuilder UseSerilogExtensions(this IApplicationBuilder app) { + // 获取当前程序所在的目录 + string currentDirectory = Directory.GetCurrentDirectory(); + //启用Serilog中间件 app.UseSerilogRequestLogging(); #region 通过配置文件读取日志存放位置 var appConfig = app.ApplicationServices.GetService(); - var logPath = $"{appConfig.logPath}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/"; + // var logPath = $"{appConfig.logPath}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/"; + var logPath = $"{currentDirectory}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/"; #endregion Log.Logger = new LoggerConfiguration().MinimumLevel.Information().WriteTo.Console() diff --git a/SlnMesnac.WPF/SlnMesnac.WPF.csproj b/SlnMesnac.WPF/SlnMesnac.WPF.csproj index 4ec2f07..ffca841 100644 --- a/SlnMesnac.WPF/SlnMesnac.WPF.csproj +++ b/SlnMesnac.WPF/SlnMesnac.WPF.csproj @@ -1,7 +1,7 @@  - Exe + WinExe net6.0-windows enable true diff --git a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs index 11a4e5f..362fa60 100644 --- a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs @@ -327,8 +327,12 @@ namespace SlnMesnac.WPF.ViewModel PageName = "生产统计"; break; case "Exit":// 关闭当前窗口 - //Environment.Exit(0); - Application.Current.Shutdown(); + var result = MessageBox.Show("确定要关闭程序吗?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No, MessageBoxOptions.None); + if (result== MessageBoxResult.Yes) + { + _logger.LogWarning("用户手动关闭程序"); + Application.Current.Shutdown(); + } break; case "Generate": UserContent = generateControl;