示例#1
0
文件: Logger.cs 项目: itsjs23/Pabulum
        public static void WriteLog(LogLevelL4N logLevel, String log)
        {
            if (logLevel.Equals(LogLevelL4N.DEBUG))
            {
                logger.Debug(log);
            }

            else if (logLevel.Equals(LogLevelL4N.ERROR))
            {
                logger.Error(log);
            }

            else if (logLevel.Equals(LogLevelL4N.FATAL))
            {
                logger.Fatal(log);
            }

            else if (logLevel.Equals(LogLevelL4N.INFO))
            {
                logger.Info(log);
            }

            else if (logLevel.Equals(LogLevelL4N.WARN))
            {

                logger.Warn(log);

            }
        }
示例#2
0
 public static void Write(Object Message, LogLevelL4N Level = LogLevelL4N.DEBUG)
 {
     try
     {
         if (Level.Equals(LogLevelL4N.DEBUG))
         {
             _Logger.Debug(Message.ToString());
         }
         else if (Level.Equals(LogLevelL4N.ERROR))
         {
             _Logger.Error(Message.ToString());
         }
         else if (Level.Equals(LogLevelL4N.FATAL))
         {
             _Logger.Fatal(Message.ToString());
         }
         else if (Level.Equals(LogLevelL4N.INFO))
         {
             _Logger.Info(Message.ToString());
         }
         else if (Level.Equals(LogLevelL4N.WARN))
         {
             _Logger.Warn(Message.ToString());
         }
     }
     catch { }
 }
示例#3
0
文件: Logger.cs 项目: sveroa/cleanbin
        /// <summary>
        ///
        /// </summary>
        /// <param name="logLevel"></param>
        /// <param name="log"></param>
        public static void WriteLog(LogLevelL4N logLevel, String log)
        {
            if (logLevel.Equals(LogLevelL4N.DEBUG))
            {
                logger.Debug(log);
            }

            else if (logLevel.Equals(LogLevelL4N.ERROR))
            {
                logger.Error(log);
            }

            else if (logLevel.Equals(LogLevelL4N.FATAL))
            {
                logger.Fatal(log);
            }

            else if (logLevel.Equals(LogLevelL4N.INFO))
            {
                logger.Info(log);
            }

            else if (logLevel.Equals(LogLevelL4N.WARN))
            {
                logger.Warn(log);
            }
        }
        /// <summary>
        /// It resolves module name and writes log in the file
        /// </summary>
        /// <param name="logLevel"></param>
        /// <param name="log"></param>
        public static void WriteLog(LogLevelL4N logLevel, String log)
        {
            string methodName = new System.Diagnostics.StackFrame(1, true).GetMethod().Name;
            string moduleName = new System.Diagnostics.StackFrame(1, true).GetMethod().ReflectedType.FullName;

            logger = LogManager.GetLogger(moduleName);
            if (logLevel.Equals(LogLevelL4N.DEBUG))
            {
                logger.Debug(" " + methodName + ": " + log);
            }

            else if (logLevel.Equals(LogLevelL4N.ERROR))
            {
                logger.Error(" " + methodName + ": " + log);
            }

            else if (logLevel.Equals(LogLevelL4N.FATAL))
            {
                logger.Fatal(" " + methodName + ": " + log);
            }

            else if (logLevel.Equals(LogLevelL4N.INFO))
            {
                logger.Info(" " + methodName + ": " + log);
            }

            else if (logLevel.Equals(LogLevelL4N.WARN))
            {
                logger.Warn(" " + methodName + ": " + log);
            }
        }
示例#5
0
        public static void Log(ILog ilog, LogLevelL4N level, Exception Ex)
        {
            try
            {
                logger    = ilog;
                exception = Ex;
                logLevel  = level;

                Job job = new Job(string.Format(CONST_STRINGLOGIDFORMAT, DateTime.Now.ToString(CONST_STRINGDATEFORMAT)));
                job.Run.Once();

                scheduler.SubmitJob(job, WriteLogFull);
            }
            catch
            {
            }
        }
示例#6
0
        public static void Log(ILog ilog, LogLevelL4N level, string message)
        {
            try
            {
                logger   = ilog;
                Message  = message;
                logLevel = level;

                Job job = new Job(string.Format(CONST_STRINGLOGIDFORMAT, DateTime.Now.ToString(CONST_STRINGDATEFORMAT)));
                job.Run.Once();

                scheduler.SubmitJob(job, WriteLog);
            }
            catch
            {
            }
        }
示例#7
0
文件: Logger.cs 项目: sveroa/cleanbin
        /// <summary>
        ///
        /// </summary>
        /// <param name="logLevel"></param>
        /// <param name="log"></param>
        /// <param name="tStartTime"></param>
        public static void WriteLog(LogLevelL4N logLevel, String log, DateTime tStartTime)
        {
            var elapsed = DateTime.Now - tStartTime;

            WriteLog(logLevel, log + " - Execution time: " + elapsed.TotalSeconds.ToString("#0.0###") + " sec(s)");
        }
 internal static void Write(String Message, LogLevelL4N Level = LogLevelL4N.DEBUG)
 {
     if (Level.Equals(LogLevelL4N.DEBUG))
         _Logger.Debug(Message);
     else if (Level.Equals(LogLevelL4N.ERROR))
         _Logger.Error(Message);
     else if (Level.Equals(LogLevelL4N.FATAL))
         _Logger.Fatal(Message);
     else if (Level.Equals(LogLevelL4N.INFO))
         _Logger.Info(Message);
     else if (Level.Equals(LogLevelL4N.WARN))
         _Logger.Warn(Message);
 }