Beispiel #1
0
 /// <summary>
 /// 使用一个明确的文件路径,若只有文件名则用默认
 /// </summary>
 /// <param name="configuration">配置</param>
 /// <param name="fileName"></param>
 /// <param name="directoryName"></param>
 public FileLogger(string fileName, string directoryName, LogConfiguration configuration)
 {
     SetId();
     _configuration = configuration;
     FileName       = fileName;
     DirectoryName  = directoryName;
 }
Beispiel #2
0
 //单个日志文件最大5M
 public LogEntity(LogConfiguration configuration, string dictionaryName, string fileName)
 {
     StringBuilder  = new StringBuilder(1024);
     Configuration  = configuration;
     DictionaryName = dictionaryName;
     FileName       = fileName;
     CreateTime     = DateTime.Now;
     LastWriteTime  = DateTime.Now;
 }
Beispiel #3
0
        /// <summary>
        /// 使用默认跟
        /// </summary>
        /// <param name="useDefaultRoot"></param>
        /// <param name="paths"></param>
        /// <returns></returns>
        public ILogger Create(bool useDefaultRoot, LogConfiguration configuration, params string[] paths)
        {
            if (paths == null)
            {
                throw new ArgumentNullException("paths");
            }
            if (!paths.Any())
            {
                throw new Exception("至少输入一个路径");
            }
            var logPath = "";

            if (useDefaultRoot)
            {
                logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Constants.DefaultLogDirectory);
            }
            logPath = paths.Aggregate(logPath, Path.Combine);
            return(InternalCreate(logPath, configuration));
        }
Beispiel #4
0
 private ILogger InternalCreate(string name, LogConfiguration configuration)
 {
     return(new FileLogger(name, configuration));
 }
Beispiel #5
0
 /// <summary>
 /// Creates a new FileLogger for the given full name.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="configuration"></param>
 /// <returns></returns>
 public ILogger Create(string name, LogConfiguration configuration)
 {
     return(InternalCreate(name, configuration));
 }
Beispiel #6
0
 public FileLoggerProvider(LogConfiguration configuration)
 {
     Configuration = configuration;
 }
Beispiel #7
0
 public EmptyLogger()
 {
     Configuration = new LogConfiguration();
 }
Beispiel #8
0
 public FileLogger(string logPath, LogConfiguration configuration)
 {
     SetId();
     _configuration = configuration;
     Init(logPath);
 }
Beispiel #9
0
 /// <summary>
 /// Creates a new FileLogger for the given full name.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="configuration"></param>
 /// <returns></returns>
 public ILogger Create(string name, LogConfiguration configuration)
 {
     return(_fileLoggerProvider.Create(name, configuration));
 }
Beispiel #10
0
        public FileLoggerFactory()
        {
            var configuration = new LogConfiguration();

            _fileLoggerProvider = new FileLoggerProvider(configuration);
        }