public void Log(LogEntry entry) { _logger = GetLogger(INFO); switch (entry.Severity) { case LoggingEventType.Debug: _logger.Debug(entry.Exception, entry.Message); break; case LoggingEventType.Information: _logger.Info(entry.Exception, entry.Message); break; case LoggingEventType.Warning: _logger.Warn(entry.Exception, entry.Message); break; case LoggingEventType.Error: _logger.Error(entry.Exception); break; case LoggingEventType.Fatal: _logger.Fatal(entry.Exception, entry.Message); break; default: break; } }
protected Test(ITestOutputHelper outputHelper) { var config = Logging.NLog.Configure(); var layout = config.AllTargets.OfType <TargetWithLayout>().First().Layout; // Step 2. Create targets var testTarget = new TestOutputTarget { Name = "Test", Layout = layout, }; config.AddTarget(testTarget); if (Configuration.LogEnabled("GridSum")) { TestOutputHelpers.AddTestOutputHelper(outputHelper, "Gridsum.DataflowEx", false); TestOutputHelpers.AddTestOutputHelper(outputHelper, "Gridsum.DataflowEx.PerfMon", false); } if (Configuration.LogEnabled("InMemoryStreamStore")) { TestOutputHelpers.AddTestOutputHelper(outputHelper, "InMemoryStreamStore", false); } Logging.NLog.Enable(config, LogEnabled); LogManager.Configuration = config; _logger = outputHelper.GetNLogLogger(); }
Task HandleExceptionAsync(HttpContext context, Exception exception) { NLog.ILogger debugLogger = LogManager.GetCurrentClassLogger(); debugLogger.Error(exception, exception.Message); if (!context.Response.HasStarted) { context.Response.ContentType = "application/json"; context.Response.StatusCode = (int)500; string result; if (_env.IsDevelopment()) { result = JsonConvert.SerializeObject(new { error = exception.Message }); } else { result = JsonConvert.SerializeObject(new { error = exception.Message, stackTrace = exception.StackTrace }); } return(context.Response.WriteAsync(result)); } else { return(Task.CompletedTask); } }
private void LoadLogConfig() { NLog.Config.XmlLoggingConfiguration config = new XmlLoggingConfiguration(FileHelper.GetPhysicalPath("config\\nlog.config"), false); var factory = new NLog.LogFactory(config); _DefaultLogger = factory.GetLogger("DefaultLog"); }
static Config() { try { var args = Environment.CommandLine.Split(' ', StringSplitOptions.RemoveEmptyEntries); if (args.Length > 1) { inMemorySettings[nameof(Token)] = args[1]; } config = new ConfigurationBuilder() .AddUserSecrets(Assembly.GetExecutingAssembly()) // lower priority //.AddEnvironmentVariables() .AddInMemoryCollection(inMemorySettings) // higher priority .Build(); Log = GetLog(); LoggerFactory = new NLogLoggerFactory(); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error initializing settings: " + e.Message); Console.ResetColor(); } }
/// <summary> /// Configure the log files /// </summary> private void ConfigureLogging() { var logLevel = LogLevel.Trace; var config = new LoggingConfiguration(); var logPath = this.GetExternalFilesDir(null).Path; var fileTarget = new FileTarget { Name = "File", FileName = Path.Combine(logPath, "sample.log"), ArchiveFileName = Path.Combine(logPath, "archive.{#}.log"), ArchiveEvery = FileArchivePeriod.Day, Layout = LogLayout, MaxArchiveFiles = 1 }; config.AddTarget("file", fileTarget); var fileRule = new LoggingRule("*", logLevel, fileTarget); config.LoggingRules.Add(fileRule); var consoleTarget = new ConsoleTarget() { Name = "Console", Layout = LogLayout }; config.AddTarget("console", consoleTarget); config.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, consoleTarget)); LogManager.Configuration = config; MainApplication.log = LogManager.GetCurrentClassLogger(); }
public Collector(ILogger <Collector> logger, IExtracterScheduler extracterScheduler, IMongoDbRepoAsync <IntelItem> dbRepoAsync, IWordCatalog catalog) { _logger = logger; _extracterScheduler = extracterScheduler; _dbRepoAsync = dbRepoAsync; _catalog = catalog; }
public TranslationsController(ILogger logger, IUOW uow) { _logger = logger; _logger.Debug("InstanceId: " + _instanceId); _uow = uow; }
public MultiLangStringsController(BaseIUOW uow, ILogger logger) { _logger = logger; _logger.Debug("InstanceId: " + _instanceId); _uow = uow; }
public EFRepositoryFactories(ILogger logger) { _logger = logger; _logger.Debug("InstanceId: " + _instanceId); _repositoryFactories = GetCustomFactories(); }
public HomeController(ILogger logger, IUOW uow) { _logger = logger; _uow = uow; _logger.Debug("InstanceId: " + _instanceId); }
public DiscordProgram() { _configService = BuildConfigurationService(); _services = BuildServiceProvider(_configService); _client = _services.GetRequiredService <DiscordSocketClient>(); Logger = LogManager.GetCurrentClassLogger(); }
public NLogLoggerImpl(string loggerName, NLogLoggerManager innerLogManager) { if (_innerLogger == null) { _innerLogger = innerLogManager.GetLogger(loggerName); } }
public LogBenchmark() { // Microsoft Logger _msLogger = LoggerFactory.Create(builder => builder .SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Warning) .AddConsole()) .CreateLogger <LogBenchmark>(); // NLog _nLogger = LogManager.Setup().SetupInternalLogger(builder => builder.SetMinimumLogLevel(NLog.LogLevel.Warn) .LogToConsole(true)) .GetCurrentClassLogger(); // Serilog _sLogger = new Serilog.LoggerConfiguration() .MinimumLevel.Warning() .WriteTo.Console() .CreateLogger(); // Microsoft LoggerMessage.Define _myHelloLog = LoggerMessage.Define <int>(Microsoft.Extensions.Logging.LogLevel.Information, new EventId(2, nameof(LogBenchmark)), Message); }
//this ctor is for testing only, you can give here an arbitrary list of repos public EFRepositoryFactories(IDictionary <Type, Func <IDbContext, object> > factories, ILogger logger) { _logger = logger; _repositoryFactories = factories; _logger.Debug("InstanceId: " + _instanceId); }
public TranslationsController(ILogger logger, BaseIUOW uow) { _logger = logger; _logger.Debug("InstanceId: " + _instanceId); _uow = uow; }
public Logger() { if (ConfigurationManager.AppSettings["LoggingisOn"] == "true") { logger = LogManager.GetCurrentClassLogger(); } }
static Program() { ILoggerFactory loggerFactory = new LoggerFactory(); loggerFactory.AddNLog(); LogManager.Configuration = new XmlLoggingConfiguration("NLog.config", true); NLog.ILogger _logger = NLog.LogManager.GetCurrentClassLogger(); }
public RedisClient(String connectionString, String clusterType, int monitorPort, int monitorIntervalMilliseconds) { this.config = ConfigurationOptions.Parse(connectionString); this.log = NLog.LogManager.GetLogger(nameof(RedisClient)); RedisConnect(); RedisMonitor(clusterType, monitorPort, monitorIntervalMilliseconds); }
public NLogLogger(NLog.ILogger logger) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } _logger = logger; }
public UrlMovePermanentlyFilter(IRepository <UrlMap, string> urlMapRepository, IConfiguration configuration, IRepository <HitLog, string> hitLogRepository, ILogger <UrlMovePermanentlyFilter> logger) { _urlMapRepository = urlMapRepository; _configuration = configuration; _hitLogRepository = hitLogRepository; _logger = logger; }
public ManageController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, IAuthenticationManager authenticationManager, ILogger logger) { _userManager = userManager; _signInManager = signInManager; _authenticationManager = authenticationManager; _logger = logger; _logger.Info(""); }
public Crawler(RequestClient requestClient, IOptions <Config> config, HTMLParser htmlParser, ILogger <Crawler> logger, Validation validation, TripCompare tripCompare) { _requestClient = requestClient; _config = config.Value; _htmlParser = htmlParser; _logger = logger; _validation = validation; _tripCompare = tripCompare; }
public EFRepositoryProvider(EFRepositoryFactories repositoryFactories, ILogger logger) { _repositoryFactories = repositoryFactories; _logger = logger; _logger.Debug("InstanceId: " + _instanceId); Repositories = new Dictionary <Type, object>(); }
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, IAuthenticationManager authenticationManager, ILogger logger) { _userManager = userManager; _signInManager = signInManager; _authenticationManager = authenticationManager; _logger = logger; _logger.Debug("InstanceId: " + _instanceId); }
public ConfigurationController( OcelotConfigSectionRepository sectionRepo, OcelotCompleteConfigRepository fullConfigRepo, IConfigurationValidator validator) { _sectionRepo = sectionRepo; _fullConfigRepo = fullConfigRepo; _validator = new OcelotConfigValidation(_sectionRepo, validator); _logger = LogManager.GetLogger("apigatewayadmin"); }
public UOW(IEFRepositoryProvider repositoryProvider, IDbContext dbContext, ILogger logger) { _logger = logger; _logger.Debug("InstanceId: " + _instanceId); DbContext = dbContext; repositoryProvider.DbContext = dbContext; RepositoryProvider = repositoryProvider; }
public UserClaimsController(IUOW uow, ILogger logger, ApplicationRoleManager roleManager, ApplicationSignInManager signInManager, ApplicationUserManager userManager, IAuthenticationManager authenticationManager) { _uow = uow; _logger = logger; _roleManager = roleManager; _signInManager = signInManager; _userManager = userManager; _authenticationManager = authenticationManager; _logger.Debug("InstanceId: " + _instanceId); }
public UserLoginsController(IUOW uow, ILogger logger, ApplicationRoleManager roleManager, ApplicationSignInManager signInManager, ApplicationUserManager userManager, IAuthenticationManager authenticationManager) { _uow = uow; _logger = logger; _roleManager = roleManager; _signInManager = signInManager; _userManager = userManager; _authenticationManager = authenticationManager; _logger.Debug("InstanceId: " + _instanceId); }
public Logger(bool logON) { if (logON) { _logger = LogManager.GetLogger("MusicStoreLogger"); } else { _logger = null; } }
public LogNLog(string name, Func <string> getAlias) { this.name = name; loger = LogManager.GetLogger(name); this.getAlias = getAlias; IsDebugEnabled = loger.IsDebugEnabled; IsInfoEnabled = loger.IsInfoEnabled; IsWarnEnabled = loger.IsWarnEnabled; IsErrorEnabled = loger.IsErrorEnabled; IsFatalEnabled = loger.IsFatalEnabled; IsTraceEnabled = loger.IsEnabled(LogLevel.Trace); }
public LogNLog(string name) { this.name = name; loger = NLog.LogManager.GetLogger(name); IsDebugEnabled = loger.IsDebugEnabled; IsInfoEnabled = loger.IsInfoEnabled; IsWarnEnabled = loger.IsWarnEnabled; IsErrorEnabled = loger.IsErrorEnabled; IsFatalEnabled = loger.IsFatalEnabled; IsTraceEnabled = loger.IsEnabled(LogLevel.Trace); }
public DataBaseContext(ILogger logger) : base ("name = TournamentDBConnection") { _logger = logger; _logger.Debug("InstanceId: " + _instanceId); //Database.SetInitializer(new MigrateDatabaseToLatestVersion<DataBaseContext,MigrationConfiguration>()); Database.SetInitializer(new DatabaseInitializer()); #if DEBUG Database.Log = s => Trace.Write(s); #endif this.Database.Log = s => _logger.Info((s.Contains("SELECT") || s.Contains("UPDATE") || s.Contains("DELETE") || s.Contains("INSERT")) ? "\n" + s.Trim() : s.Trim()); }
public NLoggerProxy(NLog.ILogger logger) { instance = logger; }
public NLogger() { logger = LogManager.GetLogger("Application"); }
public NLogLogger(NLog.ILogger logger) { if (logger == null) throw new ArgumentNullException(nameof(logger)); _logger = logger; }
public NLoggerCore(string name, INlogConfiguration configuration) { LogManager.Configuration = configuration.GetConfiguration(); _logger = LogManager.GetLogger(name); }