コード例 #1
0
        protected override void InitializeTarget()
        {
            var host     = Host?.Render(LogEventInfo.CreateNullEvent());
            var password = Password?.Render(LogEventInfo.CreateNullEvent());

            var renderedPort = Port.Render(LogEventInfo.CreateNullEvent());

            if (!int.TryParse(renderedPort, out var port))
            {
                throw new Exception($"Unable to parse Port:{renderedPort}");
            }
            var db = 0;

            if (Db != null)
            {
                var renderedDb = Db.Render(LogEventInfo.CreateNullEvent());
                if (!int.TryParse(renderedDb, out db))
                {
                    InternalLogger.Warn($"{nameof(RedisTarget)}: Unable to parse db as a number: {renderedDb} falling back to the default db 0");
                }
            }

            _redisConnectionManager = CreateConnectionManager(host, port, db, password);
            _redisConnectionManager.InitializeConnection();

            base.InitializeTarget();
        }
コード例 #2
0
ファイル: RedisTarget.cs プロジェクト: gamingrobot/NLog.Redis
        protected override void InitializeTarget()
        {
            _redisConnectionManager = CreateConnectionManager();
            _redisConnectionManager.InitializeConnection();

            base.InitializeTarget();
        }