/// <summary> /// 写登陆日志 /// </summary> /// <param name="data">日志内容</param> /// <param name="level">日志级别</param> /// <returns>true:成功;false:失败</returns> public override bool WriteLoginLog(LoginLogEventData data, int level) { if (level < this.logLevel) { return(true); } data.StationID = this.StationID; data.SystemID = this.SystemID; return(RollingFileAppender.SimpleFileLog(PrepareFileName("", LogCategory.Login), data.ToString())); }
/// <summary> /// 写日志 /// </summary> /// <param name="message">日志内容</param> /// <param name="level">日志级别</param> /// <param name="category">日志种类</param> /// <returns></returns> public bool WriteLogWithCatetory(string message, int level, string category) { if (level < this.logLevel) { return(true); } try { string dt = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string msg = String.Format("日志时间:{0},工作站:{1},子系统:{2},日志级别:{3},日志内容:{4}", dt, StationID, SystemID, logLevel.ToString(), message); return(RollingFileAppender.SimpleFileLog(PrepareFileName("", category), msg)); } catch (Exception) { return(false); } }