public void Write(LogEvent log)
 {
     using (LogServiceClient client = new LogServiceClient())
     {
         LogService.LogEvent l = new LogService.LogEvent();
         l.AppId = log.AppId;
         l.Caption = log.Caption;
         l.IPAddress = log.IPAddress;
         l.Level = (LogService.LogLevel)log.Level;
         l.LogTime = log.LogTime;
         l.Message = log.Message;
         l.Reporter = log.Reporter;
         l.SystemInfo = log.SystemInfo;
         client.Write(l);
     }
 }
Beispiel #2
0
 static void write(LogEvent log)
 {
     try
     {
         ILogProvider logger = new RefObjectCreator().Create<ILogProvider>();
         if (logger == null)
             logger = new LogServiceProvider();
         logger.Write(log);
     }
     catch (Exception exc)
     {
         try
         {
             string message = "ServiceError:{0}\n\nClientIP:{1}\nAppID:{2}\nMessage:{3}".FormatArgs(
                 exc,
                 log.IPAddress,
                 log.AppId,
                 log.Message);
             System.Diagnostics.EventLog eventLog = new System.Diagnostics.EventLog();
             eventLog.Log = "Application";
             eventLog.Source = "LogService";
             if (message.Length > 5000)
                 message = message.Substring(0, 5000);
             eventLog.WriteEntry(message, System.Diagnostics.EventLogEntryType.Error);
         }
         catch { }
     }
 }
Beispiel #3
0
 public static void Write(LogEvent log)
 {
     try
     {
         AsyncDelegate ad = new AsyncDelegate(write);
         ad.BeginInvoke(log, new AsyncCallback(CallbackMethod), ad);
     }
     catch { }
 }
Beispiel #4
0
 public static void Write(string caption, string message, LogLevel level,
     string ipAddress, string clientInfo, string reporter)
 {
     LogEvent log = new LogEvent();
     log.AppId = ConfigurationManager.AppSettings["AppLogId"];
     log.IPAddress = ipAddress;
     log.Level = level;
     log.Caption = caption;
     log.Message = message;
     log.Reporter = reporter;
     log.SystemInfo = clientInfo;
     Write(log);
 }