Ejemplo n.º 1
0
        public void LogMessage(string source, string message, EventLogSeverity severity)
        {
            var logInfo = new LogInfo();
            var user    = DnnUserController.Instance.GetCurrentUserInfo();

            logInfo.LogUserID   = user != null ? user.UserID : -1;
            logInfo.LogPortalID = PortalSettings.Current != null ? PortalSettings.Current.PortalId : -1;
            logInfo.LogTypeKey  = LOGTYPE_MESSAGE;
            logInfo.AddProperty("Severity", severity.ToString());
            logInfo.LogProperties.Add(new LogDetailInfo("Source", source));
            logInfo.LogProperties.Add(new LogDetailInfo("Message", message));

            var log = new EventLogController();

            log.AddLog(logInfo);
        }
Ejemplo n.º 2
0
        public void LogException(Exception ex, EventLogSeverity severity)
        {
            var logInfo = new LogInfo();
            var user    = DnnUserController.Instance.GetCurrentUserInfo();

            logInfo.LogUserID   = user != null ? user.UserID : -1;
            logInfo.LogPortalID = DnnGlobal.Instance.GetPortalId();
            logInfo.LogTypeKey  = LOGTYPE_EXCEPTION;
            logInfo.AddProperty("Severity", severity.ToString());

            var exception4 = new BasePortalException(ex.ToString(), ex);

            logInfo.LogProperties.Add(new LogDetailInfo("AssemblyVersion", exception4.AssemblyVersion));
            logInfo.LogProperties.Add(new LogDetailInfo("PortalID", exception4.PortalID.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("PortalName", exception4.PortalName));
            logInfo.LogProperties.Add(new LogDetailInfo("UserID", exception4.UserID.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("UserName", exception4.UserName));
            logInfo.LogProperties.Add(new LogDetailInfo("ActiveTabID", exception4.ActiveTabID.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("ActiveTabName", exception4.ActiveTabName));
            logInfo.LogProperties.Add(new LogDetailInfo("RawURL", exception4.RawURL));
            logInfo.LogProperties.Add(new LogDetailInfo("AbsoluteURL", exception4.AbsoluteURL));
            logInfo.LogProperties.Add(new LogDetailInfo("AbsoluteURLReferrer", exception4.AbsoluteURLReferrer));
            logInfo.LogProperties.Add(new LogDetailInfo("UserAgent", exception4.UserAgent));
            logInfo.LogProperties.Add(new LogDetailInfo("DefaultDataProvider", exception4.DefaultDataProvider));
            logInfo.LogProperties.Add(new LogDetailInfo("ExceptionGUID", exception4.ExceptionGUID));
            logInfo.LogProperties.Add(new LogDetailInfo("InnerException", exception4.InnerException.Message));
            logInfo.LogProperties.Add(new LogDetailInfo("FileName", exception4.FileName));
            logInfo.LogProperties.Add(new LogDetailInfo("FileLineNumber", exception4.FileLineNumber.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("FileColumnNumber", exception4.FileColumnNumber.ToString()));
            logInfo.LogProperties.Add(new LogDetailInfo("Method", exception4.Method));
            logInfo.LogProperties.Add(new LogDetailInfo("StackTrace", exception4.StackTrace));
            logInfo.LogProperties.Add(new LogDetailInfo("Message", exception4.Message));
            logInfo.LogProperties.Add(new LogDetailInfo("Source", exception4.Source));

            var log = new EventLogController();

            log.AddLog(logInfo);
        }