/// <summary> /// 日志入口 /// </summary> /// <param name="loglevel"></param> /// <param name="title"></param> /// <param name="obj"></param> void Log(LogLevel loglevel, string title, params object[] obj) { if (string.IsNullOrEmpty(title.Trim())) { throw new Exception("非调试信息的日志,标题不允许为空"); } try { lock (ObjectExtension.Locker) { LogConfigBase config = GetConfig(_logName); if (config.Loglevel > loglevel) { return; //判断日志级别,不正确的级别就不记日志了 } switch (config.Utils) { case LogUtils.Log4Net: { Log4Net.Log(config, _logName, loglevel, title, obj); break; } } } } catch (DllNotFoundException ex) { throw new Exception("未找到组件" + ex.Source); } catch (FileNotFoundException ex) { throw new Exception("未找到组件" + ex.FileName); } catch (JsonReaderException ex) { throw new Exception("配置文件:" + ex.Source + "错误:" + ex.Message + ".请删除或修复配置文件"); } catch (IOException ex) { throw new Exception(ex.Message); } catch (Exception ex) { //其他错误就不抛了 throw ex; } }