コード例 #1
0
        public override void AddLog(LogInfo logInfo)
        {
            string configPortalID = logInfo.LogPortalID != Null.NullInteger
                                        ? logInfo.LogPortalID.ToString()
                                        : "*";
            var logTypeConfigInfo = GetLogTypeConfigInfoByKey(logInfo.LogTypeKey, configPortalID);

            if (logTypeConfigInfo == null || logTypeConfigInfo.LoggingIsActive == false)
            {
                return;
            }
            logInfo.LogConfigID = logTypeConfigInfo.ID;
            var logQueueItem = new LogQueueItem {
                LogInfo = logInfo, LogTypeConfigInfo = logTypeConfigInfo
            };

            //SchedulingProvider scheduler = SchedulingProvider.Instance();
            //if (scheduler == null || logInfo.BypassBuffering || SchedulingProvider.Enabled == false  || scheduler.GetScheduleStatus() == ScheduleStatus.STOPPED || !Host.EventLogBuffer)
            //{
            //    WriteLog(logQueueItem);
            //}
            //else
            //{
            //    LogQueue.Add(logQueueItem);
            //}
            LogQueue.Add(logQueueItem);
        }
コード例 #2
0
 public override void PurgeLogBuffer()
 {
     if (!LockQueueLog.TryEnterWriteLock(WriterLockTimeout))
     {
         return;
     }
     try
     {
         for (int i = LogQueue.Count - 1; i >= 0; i += -1)
         {
             LogQueueItem logQueueItem = LogQueue[i];
             //in case the log was removed
             //by another thread simultaneously
             if (logQueueItem != null)
             {
                 WriteLog(logQueueItem);
                 LogQueue.Remove(logQueueItem);
             }
         }
     }
     finally
     {
         LockQueueLog.ExitWriteLock();
     }
     DataProvider.Instance().PurgeLog();
 }
コード例 #3
0
        private static void WriteLog(LogQueueItem logQueueItem)
        {
            LogTypeConfigInfo logTypeConfigInfo = null;

            try
            {
                logTypeConfigInfo = logQueueItem.LogTypeConfigInfo;
                if (logTypeConfigInfo != null)
                {
                    LogInfo objLogInfo    = logQueueItem.LogInfo;
                    string  logProperties = objLogInfo.LogProperties.Serialize();
                    DataProvider.Instance().AddLog(objLogInfo.LogGUID,
                                                   objLogInfo.LogTypeKey,
                                                   objLogInfo.LogUserID,
                                                   objLogInfo.LogUserName,
                                                   objLogInfo.LogPortalID,
                                                   objLogInfo.LogPortalName,
                                                   objLogInfo.LogCreateDate,
                                                   objLogInfo.LogServerName,
                                                   logProperties,
                                                   Convert.ToInt32(objLogInfo.LogConfigID),
                                                   objLogInfo.Exception,
                                                   logTypeConfigInfo.EmailNotificationIsActive);
                    if (logTypeConfigInfo.EmailNotificationIsActive)
                    {
                        if (LockNotif.TryEnterWriteLock(ReaderLockTimeout))
                        {
                            try
                            {
                                if (logTypeConfigInfo.NotificationThreshold == 0)
                                {
                                    string str = logQueueItem.LogInfo.Serialize();
                                    //Mail.Mail.SendEmail(logTypeConfigInfo.MailFromAddress, logTypeConfigInfo.MailToAddress, "Event Notification", string.Format("<pre>{0}</pre>", HttpUtility.HtmlEncode(str)));
                                }
                            }
                            finally
                            {
                                LockNotif.ExitWriteLock();
                            }
                        }
                    }
                }
            }
            catch (SqlException exc)
            {
                Logger.Error(exc);
                WriteError(logTypeConfigInfo, exc, "SQL Exception", SqlUtils.TranslateSQLException(exc));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                WriteError(logTypeConfigInfo, exc, "Unhandled Error", exc.Message);
            }
        }