コード例 #1
0
ファイル: Logger.cs プロジェクト: satishsinghh/Xebia
        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;
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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");
        }
コード例 #5
0
ファイル: Config.cs プロジェクト: MSuih/discord-bot
        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();
            }
        }
コード例 #6
0
        /// <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();
        }
コード例 #7
0
 public Collector(ILogger <Collector> logger, IExtracterScheduler extracterScheduler, IMongoDbRepoAsync <IntelItem> dbRepoAsync, IWordCatalog catalog)
 {
     _logger             = logger;
     _extracterScheduler = extracterScheduler;
     _dbRepoAsync        = dbRepoAsync;
     _catalog            = catalog;
 }
コード例 #8
0
        public TranslationsController(ILogger logger, IUOW uow)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            _uow = uow;
        }
コード例 #9
0
        public MultiLangStringsController(BaseIUOW uow, ILogger logger)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            _uow = uow;
        }
コード例 #10
0
ファイル: EFRepositoryFactories.cs プロジェクト: ktilk/Storex
        public EFRepositoryFactories(ILogger logger)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            _repositoryFactories = GetCustomFactories();
        }
コード例 #11
0
ファイル: HomeController.cs プロジェクト: viilveer/vr2_exam
        public HomeController(ILogger logger, IUOW uow)
        {
            _logger = logger;
            _uow    = uow;

            _logger.Debug("InstanceId: " + _instanceId);
        }
コード例 #12
0
 public DiscordProgram()
 {
     _configService = BuildConfigurationService();
     _services      = BuildServiceProvider(_configService);
     _client        = _services.GetRequiredService <DiscordSocketClient>();
     Logger         = LogManager.GetCurrentClassLogger();
 }
コード例 #13
0
 public NLogLoggerImpl(string loggerName, NLogLoggerManager innerLogManager)
 {
     if (_innerLogger == null)
     {
         _innerLogger = innerLogManager.GetLogger(loggerName);
     }
 }
コード例 #14
0
    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);
    }
コード例 #15
0
ファイル: EFRepositoryFactories.cs プロジェクト: ktilk/Storex
        //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);
        }
コード例 #16
0
        public TranslationsController(ILogger logger, BaseIUOW uow)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            _uow = uow;
        }
コード例 #17
0
 public Logger()
 {
     if (ConfigurationManager.AppSettings["LoggingisOn"] == "true")
     {
         logger = LogManager.GetCurrentClassLogger();
     }
 }
コード例 #18
0
        static Program()
        {
            ILoggerFactory loggerFactory = new LoggerFactory();

            loggerFactory.AddNLog();
            LogManager.Configuration = new XmlLoggingConfiguration("NLog.config", true);
            NLog.ILogger _logger = NLog.LogManager.GetCurrentClassLogger();
        }
コード例 #19
0
        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);
        }
コード例 #20
0
 public NLogLogger(NLog.ILogger logger)
 {
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     _logger = logger;
 }
コード例 #21
0
 public UrlMovePermanentlyFilter(IRepository <UrlMap, string> urlMapRepository, IConfiguration configuration,
                                 IRepository <HitLog, string> hitLogRepository,
                                 ILogger <UrlMovePermanentlyFilter> logger)
 {
     _urlMapRepository = urlMapRepository;
     _configuration    = configuration;
     _hitLogRepository = hitLogRepository;
     _logger           = logger;
 }
コード例 #22
0
 public ManageController(ApplicationUserManager userManager, ApplicationSignInManager signInManager,
                         IAuthenticationManager authenticationManager, ILogger logger)
 {
     _userManager           = userManager;
     _signInManager         = signInManager;
     _authenticationManager = authenticationManager;
     _logger = logger;
     _logger.Info("");
 }
コード例 #23
0
 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;
 }
コード例 #24
0
        public EFRepositoryProvider(EFRepositoryFactories repositoryFactories, ILogger logger)
        {
            _repositoryFactories = repositoryFactories;
            _logger = logger;

            _logger.Debug("InstanceId: " + _instanceId);

            Repositories = new Dictionary <Type, object>();
        }
コード例 #25
0
        public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager,
                                 IAuthenticationManager authenticationManager, ILogger logger)
        {
            _userManager           = userManager;
            _signInManager         = signInManager;
            _authenticationManager = authenticationManager;
            _logger = logger;

            _logger.Debug("InstanceId: " + _instanceId);
        }
コード例 #26
0
 public ConfigurationController(
     OcelotConfigSectionRepository sectionRepo,
     OcelotCompleteConfigRepository fullConfigRepo,
     IConfigurationValidator validator)
 {
     _sectionRepo    = sectionRepo;
     _fullConfigRepo = fullConfigRepo;
     _validator      = new OcelotConfigValidation(_sectionRepo, validator);
     _logger         = LogManager.GetLogger("apigatewayadmin");
 }
コード例 #27
0
ファイル: UOW.cs プロジェクト: viilveer/vr2_exam
        public UOW(IEFRepositoryProvider repositoryProvider, IDbContext dbContext, ILogger logger)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            DbContext = dbContext;

            repositoryProvider.DbContext = dbContext;
            RepositoryProvider           = repositoryProvider;
        }
コード例 #28
0
        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);
        }
コード例 #29
0
        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);
        }
コード例 #30
0
ファイル: Logger.cs プロジェクト: davidyc/davidyc-D1-D2
 public Logger(bool logON)
 {
     if (logON)
     {
         _logger = LogManager.GetLogger("MusicStoreLogger");
     }
     else
     {
         _logger = null;
     }
 }
コード例 #31
0
ファイル: Log.cs プロジェクト: julthep/CommunityServer
        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);
        }
コード例 #32
0
ファイル: Log.cs プロジェクト: vishalbelsare/CommunityServer
        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);
        }
コード例 #33
0
        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());
        }
コード例 #34
0
ファイル: NLoggerProxy.cs プロジェクト: IronSlug/elys
 public NLoggerProxy(NLog.ILogger logger)
 {
     instance = logger;
 }
コード例 #35
0
ファイル: NLogger.cs プロジェクト: yimogit/YimoFramework
 public NLogger()
 {
     logger = LogManager.GetLogger("Application");
 }
コード例 #36
0
ファイル: NLogLogger.cs プロジェクト: emgdev/Nybus
        public NLogLogger(NLog.ILogger logger)
        {
            if (logger == null) throw new ArgumentNullException(nameof(logger));
            _logger = logger;

        }
コード例 #37
0
ファイル: NLoggerCore.cs プロジェクト: andrewleaf/CodeKata
 public NLoggerCore(string name, INlogConfiguration configuration)
 {
     LogManager.Configuration = configuration.GetConfiguration();
     _logger = LogManager.GetLogger(name);
 }