Anonymous
В приложении Symfony 7 Monolog не входит в prod.log
Сообщение
Anonymous » 21 июн 2024, 15:59
Как сказано в заголовке, мое приложение Symfony 7 использует монолог для ведения журнала, но работает не на уровне продукта, а только на уровне отладки. «prod.log» остается пустым, даже когда я вызываю ошибки или использую библиотеку Psr\Log\LoggerInterface.
В .env среда устанавливается как APP_ENV=prod
Это мой файл monolog.yaml:
Код: Выделить всё
monolog:
channels:
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
when@dev:
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]
when@test:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
channels: ["!event"]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
when@prod:
monolog:
handlers:
main:
type: fingers_crossed
action_level: debug
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
nested:
type: stream
# path: php://stderr
path: '%kernel.logs_dir%/%kernel.environment%.log'
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
deprecation:
type: stream
channels: [deprecation]
# path: php://stderr
path: '%kernel.logs_dir%/%kernel.environment%.log'
formatter: monolog.formatter.json
Это мой файл композитора.json:
Код: Выделить всё
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"doctrine/doctrine-bundle": "*",
"doctrine/orm": "*",
"symfony/console": "7.0.*",
"symfony/debug-bundle": "7.0.*",
"symfony/dotenv": "7.0.*",
"symfony/flex": "^2",
"symfony/form": "7.0.*",
"symfony/framework-bundle": "7.0.*",
"symfony/monolog-bundle": "^3.10",
"symfony/runtime": "7.0.*",
"symfony/security-bundle": "7.0.*",
"symfony/twig-bundle": "7.0.*",
"symfony/yaml": "7.0.*"
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*",
"symfony/polyfill-php82": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.0.*"
}
},
"require-dev": {
"symfony/stopwatch": "7.0.*",
"symfony/web-profiler-bundle": "7.0.*"
}
}
Мой файл Bundles.php
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/78652484/in-symfony-7-app-monolog-is-not-logging-in-prod-log[/url]
1718974797
Anonymous
Как сказано в заголовке, мое приложение Symfony 7 использует монолог для ведения журнала, но работает не на уровне продукта, а только на уровне отладки. «prod.log» остается пустым, даже когда я вызываю ошибки или использую библиотеку Psr\Log\LoggerInterface. В .env среда устанавливается как APP_ENV=prod Это мой файл monolog.yaml: [code]monolog: channels: - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists when@dev: monolog: handlers: main: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug channels: ["!event"] # uncomment to get logging in your browser # you may have to allow bigger header sizes in your Web server configuration #firephp: # type: firephp # level: info #chromephp: # type: chromephp # level: info console: type: console process_psr_3_messages: false channels: ["!event", "!doctrine", "!console"] when@test: monolog: handlers: main: type: fingers_crossed action_level: error handler: nested excluded_http_codes: [404, 405] channels: ["!event"] nested: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug when@prod: monolog: handlers: main: type: fingers_crossed action_level: debug handler: nested excluded_http_codes: [404, 405] buffer_size: 50 # How many messages should be saved? Prevent memory leaks nested: type: stream # path: php://stderr path: '%kernel.logs_dir%/%kernel.environment%.log' level: debug formatter: monolog.formatter.json console: type: console process_psr_3_messages: false channels: ["!event", "!doctrine"] deprecation: type: stream channels: [deprecation] # path: php://stderr path: '%kernel.logs_dir%/%kernel.environment%.log' formatter: monolog.formatter.json [/code] Это мой файл композитора.json: [code]{ "type": "project", "license": "proprietary", "minimum-stability": "stable", "prefer-stable": true, "require": { "php": ">=8.2", "ext-ctype": "*", "ext-iconv": "*", "doctrine/doctrine-bundle": "*", "doctrine/orm": "*", "symfony/console": "7.0.*", "symfony/debug-bundle": "7.0.*", "symfony/dotenv": "7.0.*", "symfony/flex": "^2", "symfony/form": "7.0.*", "symfony/framework-bundle": "7.0.*", "symfony/monolog-bundle": "^3.10", "symfony/runtime": "7.0.*", "symfony/security-bundle": "7.0.*", "symfony/twig-bundle": "7.0.*", "symfony/yaml": "7.0.*" }, "config": { "allow-plugins": { "php-http/discovery": true, "symfony/flex": true, "symfony/runtime": true }, "sort-packages": true }, "autoload": { "psr-4": { "App\\": "src/" } }, "autoload-dev": { "psr-4": { "App\\Tests\\": "tests/" } }, "replace": { "symfony/polyfill-ctype": "*", "symfony/polyfill-iconv": "*", "symfony/polyfill-php72": "*", "symfony/polyfill-php73": "*", "symfony/polyfill-php74": "*", "symfony/polyfill-php80": "*", "symfony/polyfill-php81": "*", "symfony/polyfill-php82": "*" }, "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ] }, "conflict": { "symfony/symfony": "*" }, "extra": { "symfony": { "allow-contrib": false, "require": "7.0.*" } }, "require-dev": { "symfony/stopwatch": "7.0.*", "symfony/web-profiler-bundle": "7.0.*" } } [/code] Мой файл Bundles.php [code] Подробнее здесь: [url]https://stackoverflow.com/questions/78652484/in-symfony-7-app-monolog-is-not-logging-in-prod-log[/url]