Пример #1
0
 public static ILoggerFactory AddAliyunLogger(
     this ILoggerFactory loggerFactory,
     Microsoft.Extensions.Logging.Aliyun.AliyunLoggerConfiguration config)
 {
     loggerFactory.AddProvider(new AliyunLoggerProvider(config));
     return(loggerFactory);
 }
Пример #2
0
        public AliyunLogger(string categoryName, AliyunLoggerConfiguration config, ILoggerProvider Provider)
        {
            this.Provider = Provider;
            if (categoryName == null)
            {
                throw new NotImplementedException("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
            }
            lock (_tmrLock)
            {
                if (null == _client)
                {
                    var client = LogServiceClientBuilders.HttpBuilder
                                 // 服务入口<endpoint>及项目名<projectName>。
                                 .Endpoint($"{config.Project_name}.{config.Region_endpoint}", config.Project_name)
                                 // 访问密钥信息。
                                 .Credential(config.AccessKeyId, config.AccessKeySecret)
                                 // 设置每次请求超时时间。
                                 .RequestTimeout(1000)
                                 .Build();

                    this.categoryName = categoryName.Clone() as string;
                    _config           = config;
                    _client           = client;

                    tmr          = new System.Timers.Timer(config.MaxDelaySecends * 1000);
                    tmr.Elapsed += Tmr_Elapsed;
                    tmr.Start();
                }
            }
        }
Пример #3
0
        public AliyunLogger(string name, AliyunLoggerConfiguration config)
        {
            lock (_tmrLock)
            {
                if (null == _client)
                {
                    var client = LogServiceClientBuilders.HttpBuilder
                                 // 服务入口<endpoint>及项目名<projectName>。
                                 .Endpoint($"{config.Project_name}.{config.Region_endpoint}", config.Project_name)
                                 // 访问密钥信息。
                                 .Credential(config.AccessKeyId, config.AccessKeySecret)
                                 // 设置每次请求超时时间。
                                 .RequestTimeout(1000)
                                 .Build();

                    _name   = name;
                    _config = config;
                    _client = client;

                    tmr          = new System.Timers.Timer(config.MaxDelaySecends * 1000);
                    tmr.Elapsed += Tmr_Elapsed;
                    tmr.Start();
                }
            }
        }
Пример #4
0
        public static ILoggerFactory AddAliyunLogger(
            this ILoggerFactory loggerFactory,
            Action <Microsoft.Extensions.Logging.Aliyun.AliyunLoggerConfiguration> configure)
        {
            var config = new Microsoft.Extensions.Logging.Aliyun.AliyunLoggerConfiguration();

            configure(config);
            return(loggerFactory.AddAliyunLogger(config));
        }
Пример #5
0
        public static ILoggingBuilder AddAliyunLogger(
            this Microsoft.Extensions.Logging.ILoggingBuilder logingBuilder,
            Action <Microsoft.Extensions.Logging.Aliyun.AliyunLoggerConfiguration> configure)
        {
            var config = new Microsoft.Extensions.Logging.Aliyun.AliyunLoggerConfiguration();

            configure(config);
            logingBuilder.AddProvider(new AliyunLoggerProvider(config));
            return(logingBuilder);
        }
Пример #6
0
 public AliyunLoggerProvider(AliyunLoggerConfiguration config)
 {
     _config = config;
 }
Пример #7
0
 public AliyunLoggerProvider(AliyunLoggerConfiguration config)
 {
     _config = config;
     AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
 }