bool ILogger.WriteCore(LogType logType, string content, Exception exception, Func <string, Exception, string> formatter) { try { if (_isDispose) { return(false); //throw new Exception("日志服务已经释放"); } content = string.Format("{0}-{1}", this.Id, content); string msg = formatter(content, exception); string directoryName = String.Format("{0}\\{1}\\{2}\\", DirectoryName.TrimEnd('\\'), DateTime.Now.ToString(this.Configuration.DirectoryDatePattern), logType.GetValue()); if (logType == LogType.Error) { Log(directoryName, FileName, msg, EmergencyWriteLogDirectory); EmergencyWriteAutoResetEvent.Set(); } else { Log(directoryName, FileName, msg, WriteLogDirectory); WriteAutoResetEvent.Set(); } return(true); } catch (Exception ex) { ILogger logger = FileLoggerFactory.Default.Create("LogError.log"); logger.WriteError("日志写入出错:", ex); return(false); } }