/// <summary> /// 初始化 - API 通用逻辑日志 /// </summary> /// <param name="_logger">系统自带日志记录工具</param> public APILogicGeneralLog(ILogger <TCategoryName> _logger) { this._logger = _logger; var path = $"./_logs/{typeof(TCategoryName).Name}/{DateTime.Now:yyyy/MM-dd/HH}.log"; path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); _fileLog = new FilePrintLog(path, Encoding.UTF8); }
public void TestCreate() { try { FileInfo fileInfo = ILogExtend.GetLogFilePath("TestFilePrintLog"); ILog log = new FilePrintLog(fileInfo, System.Text.Encoding.UTF8); log.Info("测试文件信息写入"); Assert.IsNotNull(log); Assert.IsTrue(fileInfo.Exists); string fullPath = fileInfo.FullName; Assert.IsTrue(!string.IsNullOrEmpty(fullPath)); fullPath = fullPath.Replace('\\', '/'); Assert.IsTrue(fullPath.IndexOf("/bin/Debug/") > -1); } catch (Exception ex) { Console.WriteLine(ex.Message); Assert.IsTrue(false); } }