示例#1
0
 public static LogEventMQ GenLogEvent(Type t,string message,Exception ex=null,LogLevel level = LogLevel.INFO)
 {
     LogEventMQ ret = new LogEventMQ();
     ret.HostName = CommonHelper.GetHostName();
     ret.Level = level.ToString();
     ret.ThreadName = CommonHelper.GetThreadId();
     ret.Domain = CommonHelper.GetDomain();
     ret.OS = CommonHelper.GetOSName();
     ret.LoggerName = CommonHelper.GetLoggerName(t);
     ret.TimeStamp = CommonHelper.GetLoggerDateTime(DateTime.Now);
     if (ex != null)
     {
         ret.Exception = ex.ToString() + ex.StackTrace;
         ret.Level = LogLevel.ERROR.ToString();
     }
     ret.Message = message;
     return ret;
 }
示例#2
0
 public static LogEvent CopyFromLogEventMQ(LogEventMQ mq)
 {
     if (mq == null || string.IsNullOrEmpty(mq.Id) || Guid.Parse(mq.Id).Equals(Guid.Empty))
         return null;
     LogEvent ret = new LogEvent();
     foreach (System.Reflection.PropertyInfo pi in ret.GetType().GetProperties())
     {
         object value = mq.GetType().GetProperty(pi.Name).GetValue(mq);
         if(value!=null)
             pi.SetValue(ret, value);
     }
     return ret;
 }