Exemple #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;
 }
Exemple #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;
 }
Exemple #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));
        }
Exemple #4
0
 private ILogger InternalCreate(string name, LogConfiguration configuration)
 {
     return(new FileLogger(name, configuration));
 }
Exemple #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));
 }
Exemple #6
0
 public FileLoggerProvider(LogConfiguration configuration)
 {
     Configuration = configuration;
 }
Exemple #7
0
 public EmptyLogger()
 {
     Configuration = new LogConfiguration();
 }
Exemple #8
0
 public FileLogger(string logPath, LogConfiguration configuration)
 {
     SetId();
     _configuration = configuration;
     Init(logPath);
 }
Exemple #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));
 }
Exemple #10
0
        public FileLoggerFactory()
        {
            var configuration = new LogConfiguration();

            _fileLoggerProvider = new FileLoggerProvider(configuration);
        }