定义日志文件名策略
            public Series(LogFilenameStrategy strategy1, LogFilenameStrategy strategy2)
            {
                var providers = new List <LogFilenameStrategy>();


                {
                    var series = strategy1 as Series;
                    if (series != null)
                    {
                        providers.AddRange(series._strategies);
                    }

                    else
                    {
                        providers.Add(strategy1);
                    }
                }

                {
                    var series = strategy2 as Series;
                    if (series != null)
                    {
                        providers.AddRange(series._strategies);
                    }

                    else
                    {
                        providers.Add(strategy2);
                    }
                }

                _strategies = providers.ToArray();
            }
Esempio n. 2
0
        /// <summary>
        /// 创建文本文件日志记录器
        /// </summary>
        /// <param name="filenameProvider">文件名提供程序</param>
        /// <param name="filter">日志筛选器</param>
        /// <param name="encoding">文件编码</param>
        public TextFileLogger( LogFilenameStrategy filenameProvider, LogFilter filter = null, Encoding encoding = null )
            : this(filter, encoding)
        {
            if ( filenameProvider == null )
            throw new ArgumentNullException( "filenameProvider" );

              _filenameProvider = filenameProvider;
        }
Esempio n. 3
0
        /// <summary>
        /// 创建文本文件日志记录器
        /// </summary>
        /// <param name="logDirectory">存放日志文件的目录</param>
        /// <param name="filter">日志筛选器</param>
        /// <param name="cycle">日志文件记录周期</param>
        /// <param name="prefix">文件名前缀</param>
        /// <param name="postfix">文件名后缀</param>
        /// <param name="extension">文件扩展名</param>
        /// <param name="encoding">文件编码</param>
        public TextFileLogger( DirectoryInfo logDirectory, LogFilter filter = null, LogFilenameStrategy cycle = null, string prefix = "", string postfix = "", string extension = ".log", Encoding encoding = null )
            : this(filter, encoding)
        {
            if ( logDirectory == null )
            throw new ArgumentNullException( "logDirectory" );

              cycle = cycle ?? LogFileCycles.Daily;

              _filenameProvider = logDirectory.FullName + Path.DirectorySeparatorChar + prefix + cycle + postfix + extension;
        }
Esempio n. 4
0
        /// <summary>
        /// 创建文本文件日志记录器
        /// </summary>
        /// <param name="filenameProvider">文件名提供程序</param>
        /// <param name="filter">日志筛选器</param>
        /// <param name="encoding">文件编码</param>
        public TextFileLogger(LogFilenameStrategy filenameProvider, LogFilter filter = null, Encoding encoding = null)
            : this(filter, encoding)
        {
            if (filenameProvider == null)
            {
                throw new ArgumentNullException("filenameProvider");
            }

            _filenameProvider = filenameProvider;
        }
Esempio n. 5
0
        /// <summary>
        /// 创建文本文件日志记录器
        /// </summary>
        /// <param name="logDirectory">存放日志文件的目录</param>
        /// <param name="filter">日志筛选器</param>
        /// <param name="cycle">日志文件记录周期</param>
        /// <param name="prefix">文件名前缀</param>
        /// <param name="postfix">文件名后缀</param>
        /// <param name="extension">文件扩展名</param>
        /// <param name="encoding">文件编码</param>
        public TextFileLogger(DirectoryInfo logDirectory, LogFilter filter = null, LogFilenameStrategy cycle = null, string prefix = "", string postfix = "", string extension = ".log", Encoding encoding = null)
            : this(filter, encoding)
        {
            if (logDirectory == null)
            {
                throw new ArgumentNullException("logDirectory");
            }

            cycle = cycle ?? LogFileCycles.Daily;

            _filenameProvider = logDirectory.FullName + Path.DirectorySeparatorChar + prefix + cycle + postfix + extension;
        }
            public static LogFilenameStrategy Concat(LogFilenameStrategy strategy1, LogFilenameStrategy strategy2)
            {
                var literal1 = strategy1 as Literal;

                if (literal1 != null)
                {
                    var literal2 = strategy2 as Literal;
                    if (literal2 != null)
                    {
                        return(new Literal(literal1.Text + literal2.Text));
                    }
                }

                return(new Series(strategy1, strategy2));
            }
            public Series( LogFilenameStrategy strategy1, LogFilenameStrategy strategy2 )
            {
                var providers = new List<LogFilenameStrategy>();

                {
                  var series = strategy1 as Series;
                  if ( series != null )
                providers.AddRange( series._strategies );

                  else
                providers.Add( strategy1 );
                }

                {
                  var series = strategy2 as Series;
                  if ( series != null )
                providers.AddRange( series._strategies );

                  else
                providers.Add( strategy2 );
                }

                _strategies = providers.ToArray();
            }
            public static LogFilenameStrategy Concat( LogFilenameStrategy strategy1, LogFilenameStrategy strategy2 )
            {
                var literal1 = strategy1 as Literal;
                if ( literal1 != null )
                {
                  var literal2 = strategy2 as Literal;
                  if ( literal2 != null )
                return new Literal( literal1.Text + literal2.Text );
                }

                return new Series( strategy1, strategy2 );
            }