public LogRecordTest()
        {
            this.exporter  = new InMemoryExporter <LogRecord>(this.exportedItems);
            this.processor = new TestLogRecordProcessor(this.exporter);
#if NETCOREAPP2_1
            var serviceCollection = new ServiceCollection().AddLogging(builder =>
#else
            this.loggerFactory = LoggerFactory.Create(builder =>
#endif
            {
                builder.AddOpenTelemetry(options =>
                {
                    this.options = options;
                    options
                    .AddProcessor(this.processor);
                });
                builder.AddFilter(typeof(LogRecordTest).FullName, LogLevel.Trace);
            });

#if NETCOREAPP2_1
            this.serviceProvider = serviceCollection.BuildServiceProvider();
            this.logger          = this.serviceProvider.GetRequiredService <ILogger <LogRecordTest> >();
#else
            this.logger = this.loggerFactory.CreateLogger <LogRecordTest>();
#endif
        }
Exemplo n.º 2
0
        public LogRecordTest()
        {
            this.exporter      = new InMemoryExporter <LogRecord>(this.exportedItems);
            this.processor     = new TestLogRecordProcessor(this.exporter);
            this.loggerFactory = LoggerFactory.Create(builder =>
            {
                builder.AddOpenTelemetry(options =>
                {
                    this.options = options;
                    options
                    .AddProcessor(this.processor);
                });
                builder.AddFilter(typeof(LogRecordTest).FullName, LogLevel.Trace);
            });

            this.logger = this.loggerFactory.CreateLogger <LogRecordTest>();
        }