如何在命令执行期间禁用Redis日志

时间:2017-10-18 13:59:12

标签: php symfony redis

当我运行Symfony命令(使用bin/console)时,我在输出中收到Redis日志。

例如:

$ bin/console doctrine:generate:entities AppBundle:Item

[2017-10-18 13:26:47] cache.WARNING: Failed to save key "{key}" ({type}) {"key":"%5BAppBundle%5CEntity%5CItem%40%5BAnnot%5D%5D%5B1%5D","type":"array","exception":null}
[2017-10-18 13:26:47] cache.WARNING: Failed to save key "{key}" ({type}) {"key":"%5B%5BC%5DAppBundle%5CEntity%5CItem%24property_1%40%5BAnnot%5D%5D%5B1%5D","type":"integer","exception":null}
[2017-10-18 13:26:47] cache.WARNING: Failed to save key "{key}" ({type}){"key":"%5B%5BC%5DAppBundle%5CEntity%5CItem%24property_2%40%5BAnnot%5D%5D%5B1%5D","type":"integer","exception":null}
Generating entity "AppBundle\Entity\Item"
[2017-10-18 13:26:47] cache.WARNING: Failed to save key "{key}" ({type}) {"key":"%5B%5BC%5DAppBundle%5CEntity%5CItem%24property_3%40%5BAnnot%5D%5D%5B1%5D","type":"integer","exception":null}
... and at least 100 more

 > backing up Item.php to Item.php~
 > generating AppBundle\Entity\Item

这使命令的实际输出难以阅读。

1 个答案:

答案 0 :(得分:1)

snc_redis.phpredis.default / Snc\RedisBundle\Client\Phpredis\Client服务只是原始\Redis类的包装器,用于添加日志记录。

您可以关闭配置实例的日志记录,也可以直接使用Redis类。

日志记录通常设置为"%kernel.debug%",这应该避免登录env = prod。

snc_redis:
    clients:
        default:
            type: predis
            alias: default
            dsn: redis://localhost
            # usually "%kernel.debug%" to enable in dev
            logging: false

如果您没有使用sncRedis,我们需要更多关于您使用哪种机制才能提供帮助的信息。