本文整理汇总了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;
}
示例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(); };
}
示例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);
}
示例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;
}
示例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>());
}
示例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);
}
示例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);
}
示例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;
}
示例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
});
}
示例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");
}
示例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");
}
示例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();
}
示例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");
}
示例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();
}
示例15: ScriptCsProjectSystem
public ScriptCsProjectSystem(OmnisharpWorkspace workspace, IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ScriptCsContext scriptCsContext)
{
_workspace = workspace;
_env = env;
_scriptCsContext = scriptCsContext;
_logger = loggerFactory.CreateLogger<ScriptCsProjectSystem>();
}