示例#1
0
        protected override void Write(LogEventInfo logEvent)
        {
            var message       = Layout.Render(logEvent);
            var key           = Key?.Render(logEvent);
            var redisDatabase = _redisConnectionManager.GetDatabase();

            switch (DataType)
            {
            case RedisDataType.List:
                redisDatabase.ListRightPush(key, message);
                break;

            case RedisDataType.Channel:
                redisDatabase.Publish(key, message);
                break;

            default:
                throw new Exception($"The required {nameof(DataType)} property was not defined or is invalid. Consider specifying either {nameof(RedisDataType.List)} or {nameof(RedisDataType.Channel)}");
            }
        }
示例#2
0
        protected override void Write(LogEventInfo logEvent)
        {
            var message       = Layout.Render(logEvent);
            var key           = _key?.Render(logEvent);
            var redisDatabase = _redisConnectionManager.GetDatabase();

            switch (DataType)
            {
            case RedisDataType.List:
                redisDatabase.ListRightPush(key, message);
                break;

            case RedisDataType.Channel:
                redisDatabase.Publish(key, message);
                break;

            default:
                throw new Exception("no data type defined for redis");
            }
        }