Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mExLogAttr"></param>
        /// <param name="job"></param>
        /// <param name="MethodName"></param>
        /// <param name="ex"></param>
        /// <param name="errorLevel"></param>
        private void WriteExLog(
            WriteExceptionLogAttribute mExLogAttr,
            JobData job,
            string MethodName,
            Exception ex,
            ErrorLevelAttribute errorLevel)
        {
            Logger loggerInnerEx = null;
            int    entry         = (int)mExLogAttr.WriteLogType;

            switch (entry)
            {
            case 1:
                //動態取得 FileLog 的 NLog Configuration.
                loggerInnerEx = NLogHelper.GetErrorFileLogConfig(LogLevel.Error);
                LoggerExWriter(job, loggerInnerEx, MethodName, ex, errorLevel);
                break;

            case 2:
                //動態取得 EventLog 的 NLog Configuration.
                loggerInnerEx = NLogHelper.GetEventLogConfig(LogLevel.Error);
                LoggerExWriter(job, loggerInnerEx, MethodName, ex, errorLevel);
                break;

            case 4:
                //動態取得 EMailLog 的 NLog Configuration.
                loggerInnerEx = NLogHelper.GetEMailLogConfig(LogLevel.Error);
                LoggerExWriter(job, loggerInnerEx, MethodName, ex, errorLevel);
                break;

            case 3:     //同時寫 FileLog & 寫 EventLog.
                //動態取得 FileLog 的 NLog Configuration.
                //logger = NLogHelper.GetErrorFileLogConfig(LogLevel.Error);
                ////寫入錯誤的 FileLog
                //LoggerExWriter(loadClass, MethodName, ex, errorLevel, LoginName, ParamName);
                ////動態取得 EventLog 的 NLog Configuration.
                loggerInnerEx = NLogHelper.GetEventLogConfig(LogLevel.Error);
                LoggerExWriter(job, loggerInnerEx, MethodName, ex, errorLevel);
                break;

            case 6:     //同時寫 EventLog & Send EMail.
                //動態取得 EventLog 的 NLog Configuration.
                //logger = NLogHelper.GetEventLogConfig(LogLevel.Error);
                //LoggerExWriter(loadClass, MethodName, ex, errorLevel, LoginName, ParamName);
                ////動態取得 EMailLog 的 NLog Configuration.
                loggerInnerEx = NLogHelper.GetEMailLogConfig(LogLevel.Error);
                LoggerExWriter(job, loggerInnerEx, MethodName, ex, errorLevel);
                break;

            case 7:     //同時寫 FileLog & EventLog & Send EMail.

                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attr"></param>
        /// <param name="job"></param>
        /// <param name="MethodName"></param>
        private void WriteInfo(WriteLogAttribute attr, JobData job, string MethodName)
        {
            Logger loggerInner = null;
            int    entry       = (int)attr.WriteLogType;

            switch (entry)
            {
            case 1:
                //動態取得 FileLog 的 NLog Configuration.
                loggerInner = NLogHelper.GetFileLogConfig(LogLevel.Info);
                LoggerWriter(job, loggerInner, MethodName);
                break;

            case 2:
                //動態取得 EventLog 的 NLog Configuration.
                loggerInner = NLogHelper.GetEventLogConfig(LogLevel.Info);
                LoggerWriter(job, loggerInner, MethodName);
                break;

            case 4:
                //動態取得 EMailLog 的 NLog Configuration.
                loggerInner = NLogHelper.GetEMailLogConfig(LogLevel.Info);
                LoggerWriter(job, loggerInner, MethodName);
                break;

            case 3:     //同時寫 FileLog & 寫 EventLog.
                ////動態取得 EventLog 的 NLog Configuration.
                loggerInner = NLogHelper.GetEventLogConfig(LogLevel.Info);
                LoggerWriter(job, loggerInner, MethodName);
                break;

            case 6:     //同時寫 EventLog & Send EMail.
                ////動態取得 EMailLog 的 NLog Configuration.
                loggerInner = NLogHelper.GetEMailLogConfig(LogLevel.Info);
                LoggerWriter(job, loggerInner, MethodName);
                break;

            case 7:     //同時寫 FileLog & EventLog & Send EMail.
                ////動態取得 EMailLog 的 NLog Configuration.
                loggerInner = NLogHelper.GetEMailLogConfig(LogLevel.Info);
                LoggerWriter(job, loggerInner, MethodName);
                break;
            }
        }