当前位置: 首页>>代码示例>>C#>>正文


C# ILoggerFactory.CreateLogger方法代码示例

本文整理汇总了C#中ILoggerFactory.CreateLogger方法的典型用法代码示例。如果您正苦于以下问题:C# ILoggerFactory.CreateLogger方法的具体用法?C# ILoggerFactory.CreateLogger怎么用?C# ILoggerFactory.CreateLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILoggerFactory的用法示例。


在下文中一共展示了ILoggerFactory.CreateLogger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Connection

        public Connection(IMessageBus newMessageBus,
                          JsonSerializer jsonSerializer,
                          string baseSignal,
                          string connectionId,
                          IList<string> signals,
                          IList<string> groups,
                          ILoggerFactory loggerFactory,
                          IAckHandler ackHandler,
                          IPerformanceCounterManager performanceCounterManager,
                          IProtectedData protectedData,
                          IMemoryPool pool)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException("loggerFactory");
            }

            _bus = newMessageBus;
            _serializer = jsonSerializer;
            _baseSignal = baseSignal;
            _connectionId = connectionId;
            _signals = new List<string>(signals.Concat(groups));
            _groups = new DiffSet<string>(groups);
            _logger = loggerFactory.CreateLogger<Connection>();
            _ackHandler = ackHandler;
            _counters = performanceCounterManager;
            _protectedData = protectedData;
            _excludeMessage = m => ExcludeMessage(m);
            _pool = pool;
        }
开发者ID:leloulight,项目名称:SignalR-Server,代码行数:30,代码来源:Connection.cs

示例2: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
	    _logger = loggerFactory.CreateLogger("Test");
	    _logger.LogInformation("Starting Jacks logging");
            
	    if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseIISPlatformHandler();

            app.UseStaticFiles();
	    app.UseSignalR2();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
	    
	    _dm = new DownloadManager(_logger, GlobalHost.ConnectionManager.GetHubContext<Scraper.Hubs.ChatHub>());
	    
	    Console.CancelKeyPress += (s,e) => { _logger.LogInformation("CTRL+C detected - shutting down"); _dm.Stop(); };
        }
开发者ID:sheepshaker,项目名称:Scraper,代码行数:32,代码来源:Startup.cs

示例3: AttributeRoute

        public AttributeRoute(
            IRouter target,
            IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider,
            IInlineConstraintResolver constraintResolver,
            ILoggerFactory loggerFactory)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            if (actionDescriptorsCollectionProvider == null)
            {
                throw new ArgumentNullException(nameof(actionDescriptorsCollectionProvider));
            }

            if (constraintResolver == null)
            {
                throw new ArgumentNullException(nameof(constraintResolver));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _target = target;
            _actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider;
            _constraintResolver = constraintResolver;

            _routeLogger = loggerFactory.CreateLogger<InnerAttributeRoute>();
            _constraintLogger = loggerFactory.CreateLogger(typeof(RouteConstraintMatcher).FullName);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:33,代码来源:AttributeRoute.cs

示例4: ApiErrorHandlerMiddleware

		public ApiErrorHandlerMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
		{
			_next = next;
			_logger = loggerFactory.CreateLogger<ApiErrorHandlerMiddleware>();
			var defaultProblemDetectionHandler = new DefaultProblemDetectionHandler(loggerFactory.CreateLogger<DefaultProblemDetectionHandler>());
            _contextProblemDetectionHandler = defaultProblemDetectionHandler;
			_exceptionProblemDetectionHandler = defaultProblemDetectionHandler;
		}
开发者ID:jwaimann,项目名称:aspnet-hypermedia-api,代码行数:8,代码来源:ApiErrorHandlerMiddleware.cs

示例5: TestServiceProvider

        public TestServiceProvider(ILoggerFactory loggerFactory)
        {
            _loggerFactory = loggerFactory;
            _logger = _loggerFactory.CreateLogger<TestServiceProvider>();

            _services[typeof(ILoggerFactory)] = _loggerFactory;
            _services[typeof(IOmnisharpEnvironment)] = new FakeEnvironment();
            _services[typeof(IOmnisharpAssemblyLoader)] = new TestOmnisharpAssemblyLoader(_loggerFactory.CreateLogger<TestOmnisharpAssemblyLoader>());
        }
开发者ID:RLittlesII,项目名称:omnisharp-roslyn,代码行数:9,代码来源:FakeServiceProvider.cs

示例6: TreeRouteBuilder

        public TreeRouteBuilder(IRouter target, ILoggerFactory loggerFactory)
        {
            _target = target;
            _generatingEntries = new List<TreeRouteLinkGenerationEntry>();
            _matchingEntries = new List<TreeRouteMatchingEntry>();

            _logger = loggerFactory.CreateLogger<TreeRouter>();
            _constraintLogger = loggerFactory.CreateLogger(typeof(RouteConstraintMatcher).FullName);
        }
开发者ID:leloulight,项目名称:Routing,代码行数:9,代码来源:TreeRouteBuilder.cs

示例7: DnxProjectSystem

        public DnxProjectSystem(OmnisharpWorkspace workspace,
                                    IOmnisharpEnvironment env,
                                    IOptions<OmniSharpOptions> optionsAccessor,
                                    ILoggerFactory loggerFactory,
                                    IMetadataFileReferenceCache metadataFileReferenceCache,
                                    IApplicationLifetime lifetime,
                                    IFileSystemWatcher watcher,
                                    IEventEmitter emitter,
                                    DnxContext context)
        {
            _workspace = workspace;
            _env = env;
            _logger = loggerFactory.CreateLogger<DnxProjectSystem>();
            _metadataFileReferenceCache = metadataFileReferenceCache;
            _options = optionsAccessor.Options;
            _dnxPaths = new DnxPaths(env, _options, loggerFactory);
            _designTimeHostManager = new DesignTimeHostManager(loggerFactory, _dnxPaths);
            _packagesRestoreTool = new PackagesRestoreTool(_options, loggerFactory, emitter, context, _dnxPaths);
            _context = context;
            _watcher = watcher;
            _emitter = emitter;
            _directoryEnumerator = new DirectoryEnumerator(loggerFactory);

            lifetime.ApplicationStopping.Register(OnShutdown);
        }
开发者ID:fogzot,项目名称:monodevelop-dnx-addin,代码行数:25,代码来源:DnxProjectSystem.cs

示例8: HttpServiceGatewayMiddleware

        public HttpServiceGatewayMiddleware(
            RequestDelegate next,
            ILoggerFactory loggerFactory,
            IHttpCommunicationClientFactory httpCommunicationClientFactory,
            IOptions<HttpServiceGatewayOptions> gatewayOptions)
        {
            if (next == null)
                throw new ArgumentNullException(nameof(next));

            if (loggerFactory == null)
                throw new ArgumentNullException(nameof(loggerFactory));

            if (httpCommunicationClientFactory == null)
                throw new ArgumentNullException(nameof(httpCommunicationClientFactory));

            if (gatewayOptions?.Value == null)
                throw new ArgumentNullException(nameof(gatewayOptions));

            if (gatewayOptions.Value.ServiceName == null)
                throw new ArgumentNullException($"{nameof(gatewayOptions)}.{nameof(gatewayOptions.Value.ServiceName)}");

            // "next" is not stored because this is a terminal middleware
            _logger = loggerFactory.CreateLogger(HttpServiceGatewayDefaults.LoggerName);
            _httpCommunicationClientFactory = httpCommunicationClientFactory;
            _gatewayOptions = gatewayOptions.Value;
        }
开发者ID:CESARDELATORRE,项目名称:ServiceFabric-Http,代码行数:26,代码来源:HttpServiceGatewayMiddleware.cs

示例9: RazorViewEngine

        /// <summary>
        /// Initializes a new instance of the <see cref="RazorViewEngine" />.
        /// </summary>
        public RazorViewEngine(
            IRazorPageFactoryProvider pageFactory,
            IRazorPageActivator pageActivator,
            HtmlEncoder htmlEncoder,
            IOptions<RazorViewEngineOptions> optionsAccessor,
            ILoggerFactory loggerFactory)
        {
            _options = optionsAccessor.Value;

            if (_options.ViewLocationFormats.Count == 0)
            {
                throw new ArgumentException(
                    Resources.FormatViewLocationFormatsIsRequired(nameof(RazorViewEngineOptions.ViewLocationFormats)),
                    nameof(optionsAccessor));
            }

            if (_options.AreaViewLocationFormats.Count == 0)
            {
                throw new ArgumentException(
                    Resources.FormatViewLocationFormatsIsRequired(nameof(RazorViewEngineOptions.AreaViewLocationFormats)),
                    nameof(optionsAccessor));
            }

            _pageFactory = pageFactory;
            _pageActivator = pageActivator;
            _htmlEncoder = htmlEncoder;
            _logger = loggerFactory.CreateLogger<RazorViewEngine>();
            ViewLookupCache = new MemoryCache(new MemoryCacheOptions
            {
                CompactOnMemoryPressure = false
            });
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:35,代码来源:RazorViewEngine.cs

示例10: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            // Add the platform handler to the request pipeline.
            //app.UseIISPlatformHandler();

            // Configure the HTTP request pipeline.
            String staticFilePath = env.WebRootPath + "\\static";
            // Add MyStaticFiles static files to the request pipeline.
            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(staticFilePath),
                RequestPath = new PathString("/static")
            });
            app.UseDirectoryBrowser();

            // Add MVC to the request pipeline.
            app.UseMvc();
            // Add the following route for porting Web API 2 controllers.
            // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
            Camera.AForgeStillWrapper VC = new Camera.AForgeStillWrapper(env.WebRootPath);

            var logger = loggerFactory.CreateLogger("TestLogger");
            logger.LogDebug("Yay");
        }
开发者ID:ulkuniem,项目名称:CameraService-aforge-dnx,代码行数:29,代码来源:Startup.cs

示例11: ConfigureServices

        private void ConfigureServices(IServiceCollection services)
        {
            loggerFactory = new LoggerFactory().AddConsole(minLevel: LogLevel.Verbose);
            var logger = loggerFactory.CreateLogger(typeof(Program).FullName);

            logger.LogInformation("Logging configured");
        }
开发者ID:dneimke,项目名称:EFLibrary,代码行数:7,代码来源:Program.cs

示例12: SessionMiddleware

        /// <summary>
        /// Creates a new <see cref="SessionMiddleware"/>.
        /// </summary>
        /// <param name="next">The <see cref="RequestDelegate"/> representing the next middleware in the pipeline.</param>
        /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> representing the factory that used to create logger instances.</param>
        /// <param name="sessionStore">The <see cref="ISessionStore"/> representing the session store.</param>
        /// <param name="options">The session configuration options.</param>
        public SessionMiddleware(
            RequestDelegate next,
            ILoggerFactory loggerFactory,
            ISessionStore sessionStore,
            IOptions<SessionOptions> options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (sessionStore == null)
            {
                throw new ArgumentNullException(nameof(sessionStore));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _next = next;
            _logger = loggerFactory.CreateLogger<SessionMiddleware>();
            _options = options.Value;
            _sessionStore = sessionStore;
            _sessionStore.Connect();
        }
开发者ID:yaobos,项目名称:Session,代码行数:39,代码来源:SessionMiddleware.cs

示例13: Configure

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
      loggerFactory.AddConsole(Configuration.GetSection("Logging"));
      loggerFactory.AddDebug();

      app.UseIISPlatformHandler();

      app.UseStaticFiles();

      app.UseMvc();

      // Create a catch-all response
      app.Run(async (context) =>
      {
        var logger = loggerFactory.CreateLogger("Catchall Endpoint");
        logger.LogInformation("No endpoint found for request {path}", context.Request.Path);
        await context.Response.WriteAsync("No endpoint found.");
      });

      //add NLog to aspnet5
      loggerFactory.AddNLog();

      //configure nlog.config in your project root
      env.ConfigureNLog("nlog.config");
    }
开发者ID:juri33,项目名称:FootballCoach,代码行数:26,代码来源:Startup.cs

示例14: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            var logger = loggerFactory.CreateLogger("Startup");
            // get configroot's children
            var configs = Configuration.GetChildren()
                .Select(config => new { key = config.Key, path = config.Path, val = config.Value, })
                ;
            foreach (var config in Configuration.GetChildren())
            {
                // output config information
                logger.LogInformation($"key={config.Key},value={config.Value},path={config.Path}"
                    );
            }
            logger.LogInformation("child section");
            // get subsection
            var children = Configuration.GetSection("e");
            foreach(var config in children.GetChildren())
            {
                logger.LogInformation("key={0},value={1},path={2}"
                    , config.Key
                    , config.Value
                    , config.Path);
            }

            app.UseIISPlatformHandler();

            app.UseStaticFiles();

            app.UseMvc();
        }
开发者ID:itn3000,项目名称:Sample.CsConfig,代码行数:34,代码来源:Startup.cs

示例15: ScriptCsProjectSystem

 public ScriptCsProjectSystem(OmnisharpWorkspace workspace, IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ScriptCsContext scriptCsContext)
 {
     _workspace = workspace;
     _env = env;
     _scriptCsContext = scriptCsContext;
     _logger = loggerFactory.CreateLogger<ScriptCsProjectSystem>();
 }
开发者ID:RLittlesII,项目名称:omnisharp-roslyn,代码行数:7,代码来源:ScriptCsProjectSystem.cs


注:本文中的ILoggerFactory.CreateLogger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。