GetModelName() public method

获取错误码模块名称
public GetModelName ( ) : string
return string
Esempio n. 1
0
        /// <summary>
        /// 写入日志
        /// </summary>
        /// <param name="level">日志等级</param>
        /// <param name="err">err</param>
        private void WriteToLog(LogLevel level, SmcErr err, Exception e, string message, params object[] args)
        {
            //暂时先这样处理,保证log2console能够看到异常信息
            StringBuilder log = new StringBuilder();
            if (null != e)
            {
                log.AppendFormat("{0},{1}", e.Message, e.StackTrace);
                log.AppendLine();
                if (null != e.InnerException)
                {
                    log.AppendFormat("InnerException {0},{1}", e.InnerException.Message, e.InnerException.StackTrace);
                    log.AppendLine();
                }
            }

            if (null == args || (null != args && args.Length == 0))
            {
                log.Append(message);
            }
            else
            {
                log.AppendFormat(message, args);
            }

            LogEventInfo logEvent = new LogEventInfo(level, this.Log.Name, null, log.ToString(), null, null);
            if (null != err)
            {
                Param = err.GetXmlParamter();
                Model = err.GetModelName();
                ErrNo = err.ErrNo;
            }

            foreach (KeyValuePair<string, object> de in this.Properties)
            {
                logEvent.Properties[de.Key] = de.Value;
            }

            this.Log.Log(logEvent);
            //ClearProperties();
        }