我刚刚从 Symfony 5 迁移到 6,但出现错误
Environment variables "string:LOG_HOST", "string:LOG_PORT" are never used. Please, check your container's configuration.
但是我已经有了这些 env - 它们在 env.local 文件中设置,并且在我的 monolog 配置文件中引用它们。有什么想法吗?
monolog:
channels: [ gelf ]
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
channels: [ "!event", "!gelf" ]
nested:
type: stream
path: "php://stderr"
level: debug
console:
type: console
gelf:
level: info
type: gelf
channels: [ "gelf" ]
formatter: gelf_app_formatter
publisher:
hostname: '%env(string:LOG_HOST)%'
port: '%env(string:LOG_PORT)%'
您可以尝试一下:
'%env(resolve:LOG_HOST)%'
而不是'%env(string:LOG_HOST)%'
'%env(resolve:LOG_PORT)%'
而不是'%env(string:LOG_PORT)%'
还有另一种方法:
将“LOG_HOST”和“LOG_PORT”设置为系统的环境变量 并使用“%env(LOG_HOST)%”和“%env(LOG_PORT)%”
或
将“LOG_HOST”和“LOG_PORT”设置为.env.local并仅使用“LOG_HOST”, “LOG_PORT”而不是“%env(LOG_HOST)%”和“%env(LOG_PORT)%”