Я искал вопросы на этом сайте, но не нашел, как решить мою проблему, которая кажется простой, но я застрял ...
Я использую Symfony 4.1 с Doctrine-ODM иMonologBundle.
Я хочу определить пользовательский канал и обработчик в Monolog как вращающийся_файл.Я определил мой канал и обработчик ниже, но когда я печатаю в терминале bin/console debug:container log
, у меня нет своего собственного обработчика в списке.
Здесь мой dev / monolog.yaml:
monolog:
channels: ["foo"]
handlers:
foo:
type: rotating_file
path: "kernel.logs_dir%/%kernel_environment%.foo.log"
channels: ["foo"]
max_files: 30
level: DEBUG
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_404s:
# regex: exclude all 404 errors from the logs
- ^/
channels: ["!foo"]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: warning
console:
type: console
process_psr_3_messages: false
channels:
- "!event"
- "!doctrine"
level: warning
deprecation:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log"
deprecation_filter:
type: filter
handler: deprecation
max_level: info
channels: ["php"]
Более того, я попытался привязать его к сервису в service.yaml, например:
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
bind:
$fooLogger: "@monolog.logger.foo"
Наконец, я внедряю его в свой сервис, например:
<?php
declare(strict_types=1);
namespace App\Handler;
use Psr\Log\LoggerInterface;
class FooManager
{
/**
* @var LoggerInterface
*/
protected $fooLogger;
public function __construct(
LoggerInterface $fooLogger
) {
$this->fooLogger = $fooLogger;
}
....
}
Я всегда получаю эту ошибку: ВParameterBag.php строка 100:
Вы запросили несуществующий параметр "/ foo.".
Кажется, мне не нравится мой путь к лог-файлу, но я хочу его настроить.Как я могу удалить эту ошибку?