diff --git a/Masuit.Tools.Abstractions/Logging/LogManager.cs b/Masuit.Tools.Abstractions/Logging/LogManager.cs index 7e852417b1948b8d2f08a3af24fee609ea4be74e..b0b77cc6f3aa9dce7bfb6515d0fb974b8a034ccc 100644 --- a/Masuit.Tools.Abstractions/Logging/LogManager.cs +++ b/Masuit.Tools.Abstractions/Logging/LogManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; @@ -63,14 +63,21 @@ namespace Masuit.Tools.Logging private static AutoResetEvent Pause => new AutoResetEvent(false); + private static string logDirectory; /// /// 日志存放目录,默认日志放在当前应用程序运行目录下的logs文件夹中 /// public static string LogDirectory { - get => Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory).Any(s => s.Contains("Web.config")) ? AppDomain.CurrentDomain.BaseDirectory + @"App_Data\Logs\" : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs"); + get => logDirectory ?? Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory).Any(s => s.Contains("Web.config")) ? AppDomain.CurrentDomain.BaseDirectory + @"App_Data\Logs\" : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs"); set { + //自定义目录 + if (!Directory.Exists(value)) + { + Directory.CreateDirectory(value); + } + logDirectory = value; } }