Exemplo n.º 1
0
        /// <summary>
        /// 激活各种logger, 可以使用'|'位或运算
        /// </summary>
        ///     <param name="type">待激活的各种logger标志</param>
        ///     <param name="level">logger的级别, 默认为<see cref="LoggerLevel.Dbug"/></param>
        ///     <param name="fileName">[建议不要设置]fileLogger的文件名称</param>
        public static void Enable(Loggers type, LoggerLevel level = LoggerLevel.Dbug, string fileName = null)
        {
            if (type.HasFlag(Loggers.ConsoleLogger))
            {
                LoggerBase.EnsureCreat <ConsoleLogger>(level);
            }

            if (type.HasFlag(Loggers.DebugLogger))
            {
                LoggerBase.EnsureCreat <DebugLogger>(level);
            }

            if (type.HasFlag(Loggers.FileLogger))
            {
                LoggerBase.EnsureCreat <FileLogger>(level);
                if (fileName.IsNotNullOrEmptyOrSpace())
                {
                    FileLogger.FileName = fileName;
                }
                WriteInformation("Logger File created... Check [ROOT_OF_YOUR_APP]/log/");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 激活各种logger, 可以使用'|'位或运算
        /// </summary>
        ///     <param name="type">待激活的各种logger标志</param>
        ///     <param name="level">logger的级别, 默认为<see cref="LoggerLevel.Dbug"/></param>
        ///     <param name="fileName">[建议不要设置]fileLogger的文件名称</param>
        ///     <param name="isDetailMode">详细模式?</param>
        public static void Enable(Loggers type, bool isDetailMode, LoggerLevel level = LoggerLevel.Dbug, string fileName = null)
        {
            IsDetailMode = isDetailMode;
            if (type.HasFlag(Loggers.ConsoleLogger))
            {
                LoggerBase.EnsureCreat <ConsoleLogger>(level);
            }

            if (type.HasFlag(Loggers.DebugLogger))
            {
                LoggerBase.EnsureCreat <DebugLogger>(level);
            }

            if (type.HasFlag(Loggers.FileLogger))
            {
                LoggerBase.EnsureCreat <FileLogger>(level);
                if (fileName.IsNotNullOrEmptyOrSpace())
                {
                    FileLogger.FileName = fileName;
                }
                Info("Logger File [Created]... Check [ROOT_OF_YOUR_APP]/log/");
            }
        }