public Program() { // a DI based application would get ILoggerFactory injected instead var factory = new LoggerFactory(); // getting the logger immediately using the class's name is conventional _logger = factory.CreateLogger(typeof(Program).FullName); // providers may be added to an ILoggerFactory at any time, existing ILoggers are updated #if !DNXCORE50 factory.AddNLog(new global::NLog.LogFactory()); #endif factory.AddConsole(); factory.AddConsole((category, logLevel) => logLevel >= LogLevel.Critical && category.Equals(typeof(Program).FullName)); }
public Startup( IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory) { _logger = loggerFactory.CreateLogger<Startup>(); var configuration = new Configuration(); configuration.AddJsonFile("config.json"); configuration.AddEnvironmentVariables(); var loggingConfiguration = configuration.GetSubKey("Logging"); var serilog = new LoggerConfiguration() .MinimumLevel.Verbose() .Enrich.WithMachineName() .Enrich.WithProcessId() .Enrich.WithThreadId(); if (string.Equals(hostingEnvironment.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase)) { serilog.WriteTo.ColoredConsole(); } string elasticSearchConnectionString; if (loggingConfiguration.TryGet("ElasticSearch:Server", out elasticSearchConnectionString)) { serilog.WriteTo.ElasticSearch(node: new Uri(elasticSearchConnectionString)); } loggerFactory.AddSerilog(serilog); }
internal OwinLogger(Microsoft.Framework.Logging.ILogger logger) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } _logger = logger; }
public StoreController( ILoggerFactory loggerfactory, IServiceProvider serviceProvider, IGenreQueryService genreQueryService, IAlbumQueryService albumQueryService) { _serviceProvider = serviceProvider; _genreQueryService = genreQueryService; _albumQueryService = albumQueryService; _logger = loggerfactory.CreateLogger(nameof(StoreController)); }
public ShoppingCartController( ILoggerFactory loggerfactory, IServiceProvider serviceProvider, IAlbumQueryService albumQueryService, ICartQueryService cartQueryService, ICartCommandService cartCommandService) { _serviceProvider = serviceProvider; _albumQueryService = albumQueryService; _cartQueryService = cartQueryService; _cartCommandService = cartCommandService; _logger = loggerfactory.CreateLogger(nameof(StoreController)); }
public Program() { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() #if DNXCORE50 .WriteTo.TextWriter(Console.Out) #else .Enrich.WithMachineName() .Enrich.WithProcessId() .Enrich.WithThreadId() .WriteTo.ColoredConsole() #endif .CreateLogger(); _logger = new LoggerFactory() .AddSerilog() .CreateLogger(typeof(Program).FullName); }
public Program() { // a DI based application would get ILoggerFactory injected instead var factory = new LoggerFactory(); // getting the logger immediately using the class's name is conventional _logger = factory.CreateLogger(typeof(Program).FullName); // providers may be added to an ILoggerFactory at any time, existing ILoggers are updated #if !DNXCORE50 factory.AddNLog(new global::NLog.LogFactory()); factory.AddSerilog(new Serilog.LoggerConfiguration() .Enrich.WithMachineName() .Enrich.WithProcessId() .Enrich.WithThreadId() .MinimumLevel.Debug() .WriteTo.RollingFile("file-{Date}.txt", outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} {Level}:{EventId} [{SourceContext}] {Message}{NewLine}{Exception}") .WriteTo.Sink(new RollingFileSink("file-{Date}.json", new JsonFormatter(), null, null)) .WriteTo.Sink(new FileSink("dump.txt", new RawFormatter(), null))); #endif factory.AddConsole(); factory.AddConsole((category, logLevel) => logLevel >= LogLevel.Critical && category.Equals(typeof(Program).FullName)); }
public RestoreCommand(ILoggerFactory loggerFactory) { _loggerFactory = loggerFactory; _log = loggerFactory.CreateLogger <RestoreCommand>(); }
public static Assembly TryLoadHelp(this Assembly assembly, ZipPackage zipPackage, ILogger logger) { logger.LogInformation("Looking for xml help for {0}", assembly.Name); var helpFile = zipPackage.GetFiles().FirstOrDefault(file => file.Path.Equals(assembly.Path.Replace("dll", "xml"), StringComparison.OrdinalIgnoreCase)); if (helpFile != null) { logger.LogInformation("Found xml help for {0}", assembly.Name); var xml = XDocument.Load(helpFile.GetStream()); foreach (var member in xml.Element("doc").Element("members").Elements("member")) { var name = member.Attribute("name")?.Value; if (name == null) { continue; } try { switch (name.First()) { case 'T': { assembly.FindType(name.Substring(2))?.LoadHelp(member); break; } case 'M': { var argStart = name.IndexOf('('); if (argStart < 2) { continue; } var methodName = name.Substring(2, argStart - 2); var typeName = methodName.Substring(0, methodName.LastIndexOf('.')); methodName = methodName.Substring(methodName.LastIndexOf('.') + 1); assembly.FindType(typeName)?.Methods.FirstOrDefault(m => m.Name == methodName)?.LoadHelp(member); break; } } } catch (Exception ex) { logger.LogError("Failed to pull out help details", ex); } } } return assembly; }
public static Package ToPackage(this ZipPackage zipPackage, List<string> otherVersions, ILogger logger) { return new Package { Id = zipPackage.Id, Title = zipPackage.Title ?? zipPackage.Id, Version = zipPackage.Version.ToString(), Versions = otherVersions, Summary = zipPackage.Summary ?? zipPackage.Description, DependencySets = zipPackage.DependencySets .Select(set => set?.ToDependencySet()) .ToList(), Assemblies = zipPackage.GetFiles() .Where(file => file.Path.StartsWith("lib", StringComparison.OrdinalIgnoreCase)) .Where(file => file.Path.EndsWith("dll", StringComparison.OrdinalIgnoreCase)) .GroupBy(file => Path.GetFileNameWithoutExtension(file.Path.Split('\\').Last())) .Select(assembly => assembly.ToAssembly().TryLoadHelp(zipPackage, logger)) .ToList(), GeneratorVersion = Version, }; }
public RequestUrlLoggerMiddleware(RequestDelegate next, ILoggerFactory loggerFactory) { _next = next; _logger = loggerFactory.CreateLogger <RequestUrlLoggerMiddleware>(); }
public Class(ShellSettings shellSettings, ILogger logger) { _shellSettings = shellSettings; _logger = logger; }
public ErrorLoggingMiddleware(RequestDelegate next, ILoggerFactory loggerFactory) { _next = next; _logger = loggerFactory.CreateLogger <ErrorLoggingMiddleware>(); }
public Class(ShellSettings shellSettings,ILogger logger) { _shellSettings = shellSettings; _logger = logger; }
public LoggerReport(LogLevel logLevel, ILogger logger) { _logLevel = logLevel; _logger = logger; }
public ErrorLoggingMiddleware(RequestDelegate next, ILoggerFactory loggerFactory) { _next = next; _logger = loggerFactory.CreateLogger<ErrorLoggingMiddleware>(); }