public FileLoggerProcessor(FileLogOptions options)
        {
            _options = options;
            _logDIr = options.LogDIr;

            Init();
        }
Exemplo n.º 2
0
 public FileLogger(string name, FileLogOptions options, FileLoggerProcessor messageQueue)
 {
     if (name == null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     _options      = options;
     this.Name     = name;
     _messageQueue = messageQueue;
 }
Exemplo n.º 3
0
        private static void Valid(FileLogOptions options)
        {
            if (string.IsNullOrEmpty(options.LogDIr))
            {
                options.LogDIr = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
            }

            //1024 * 1024 =1M
            if (options.FileMaxSize < 1024 * 1024)
            {
                options.FileMaxSize = 1024 * 1024;
            }
        }
Exemplo n.º 4
0
        public static ILoggerFactory AddAixFileLog(this ILoggerFactory factory, Action <FileLogOptions> setup = null)
        {
            FileLogOptions options = new FileLogOptions();

            if (setup != null)
            {
                setup(options);
            }
            Valid(options);
            factory.AddProvider(new MyFileLoggerProvider(options));

            return(factory);
        }
Exemplo n.º 5
0
        public static ILoggingBuilder AddAixFileLog(this ILoggingBuilder factory, Action <FileLogOptions> setup = null)
        {
            FileLogOptions options = new FileLogOptions();

            if (setup != null)
            {
                setup(options);
            }
            Valid(options);
            factory.AddProvider(new MyFileLoggerProvider(options));
            if (options.logLevel.HasValue)
            {
                factory.SetMinimumLevel(options.logLevel.Value);
            }

            return(factory);
        }
 public MyFileLoggerProvider(FileLogOptions options)
 {
     _options      = options;
     _messageQueue = new FileLoggerProcessor(_options);
 }