/// <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; }
public LoggerWithFilter(Logger logger, LogFilter filter) { Contract.Assert(logger != null); Contract.Assert(filter != null); Filter = filter; InnerLogger = logger; }
/// <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; }
/// <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; }
/// <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; }
/// <summary> /// 创建一个新的日志记录器,只记录符合条件的日志 /// </summary> /// <param name="logger">内部日志记录器,符合条件的日志将使用这个日志记录器记录</param> /// <param name="filter">日志记录条件</param> /// <returns>只记录符合条件的日志的日志记录器</returns> public static Logger WithFilter( this Logger logger, LogFilter filter ) { if ( logger == null ) return null; if ( filter == null ) throw new ArgumentNullException( "filter" ); var loggerWithFilter = logger as LoggerWithFilter; if ( loggerWithFilter != null ) return new LoggerWithFilter( loggerWithFilter.InnerLogger, loggerWithFilter.Filter & filter ); else return new LoggerWithFilter( logger, filter ); }
private TextFileLogger( LogFilter filter, Encoding encoding ) : base(filter, encoding) { basePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; }
/// <summary> /// 初始化 TextFileLoggerBase 对象 /// </summary> /// <param name="filter">可选的日志筛选器</param> /// <param name="encoding">写入文件所用的编码</param> protected TextFileLoggerBase( LogFilter filter = null, Encoding encoding = null ) : base(filter) { _encoding = encoding ?? TextLogFileManager.DefaultEncoding; }
/// <summary> /// 创建 Logger 对象 /// </summary> /// <param name="filter">日志筛选器</param> protected Logger( LogFilter filter ) { _filter = filter; }
public LoggerWithFilter( Logger logger, LogFilter filter ) { Contract.Assert( logger != null ); Contract.Assert( filter != null ); Filter = filter; InnerLogger = logger; }
/// <summary> /// 创建 TextLogger 对象 /// </summary> /// <param name="filter">日志筛选器</param> protected TextLogger( LogFilter filter = null ) : base(filter) { }
/// <summary> /// 创建 ConsoleLogger 实例 /// </summary> /// <param name="filter">日志筛选器,确定哪些日志需要被记录</param> public ConsoleLogger( LogFilter filter = null ) : base(filter) { }
private TextFileLogger(LogFilter filter, Encoding encoding) : base(filter, encoding) { basePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; }
/// <summary> /// 初始化 TextFileLoggerBase 对象 /// </summary> /// <param name="filter">可选的日志筛选器</param> /// <param name="encoding">写入文件所用的编码</param> protected TextFileLoggerBase(LogFilter filter = null, Encoding encoding = null) : base(filter) { _encoding = encoding ?? TextLogFileManager.DefaultEncoding; }
/// <summary> /// 创建 ConsoleLogger 实例 /// </summary> /// <param name="filter">日志筛选器,确定哪些日志需要被记录</param> public ConsoleLogger(LogFilter filter = null) : base(filter) { }
protected TextFileLoggerBase( LogFilter filter = null, Encoding encoding = null ) : base(filter) { _encoding = encoding ?? Encoding.UTF8; }
private TextFileLogger(LogFilter filter, Encoding encoding) : base(filter, encoding) { basePath = System.IO.Directory.GetCurrentDirectory(); }
/// <summary> /// 创建 TextLogger 对象 /// </summary> /// <param name="filter">日志筛选器</param> /// <param name="timezone">时区信息(默认为UTC-0)</param> protected TextLogger(LogFilter filter = null, TimeZoneInfo timezone = null) { _timezone = timezone ?? TimeZoneInfo.Utc; }
/// <summary> /// 创建 TextLogger 对象 /// </summary> /// <param name="filter">日志筛选器</param> /// <param name="timezone">时区信息(默认为UTC-0)</param> protected TextLogger( LogFilter filter = null, TimeZoneInfo timezone = null ) { _timezone = timezone ?? TimeZoneInfo.Utc; }