捕捉 Monolog\Logger 方法的使用
Catch using of Monolog\Logger methods
当应用程序运行 Monolog\Logger 方法之一(信息、错误、警告等)并执行一些自定义代码时,我需要添加一些操作。
例如:
$this->logger->error('Some error');
应该执行错误输出 - Monolog\Logger 的基本操作,但之后通过 API 发送错误文本 ...
请阅读Symfony Monolog documentation and check out if you find any network or server handler from the list of included handlers and their configuration options。
如果没有合适的处理程序,您应该使用 service handler type, e.g. src/AppBundle/Monolog/YourApiHandler.php
which needs to implement at least the HandlerInterface , but you could also see if another class you could inherit from is more appropriate for your task, e.g. AbstractProcesssingHandler 创建自定义处理程序 class。
实现处理程序后,只需为其定义一个服务即可
# app/config/services.yml
services:
my_handler:
class: AppBundle\Monolog\YourApiHandler
并将其添加到独白配置中:
# app/config/config.yml
monolog:
handlers:
my_handler:
type: service
id: my_handler
当应用程序运行 Monolog\Logger 方法之一(信息、错误、警告等)并执行一些自定义代码时,我需要添加一些操作。
例如:
$this->logger->error('Some error');
应该执行错误输出 - Monolog\Logger 的基本操作,但之后通过 API 发送错误文本 ...
请阅读Symfony Monolog documentation and check out if you find any network or server handler from the list of included handlers and their configuration options。
如果没有合适的处理程序,您应该使用 service handler type, e.g. src/AppBundle/Monolog/YourApiHandler.php
which needs to implement at least the HandlerInterface , but you could also see if another class you could inherit from is more appropriate for your task, e.g. AbstractProcesssingHandler 创建自定义处理程序 class。
实现处理程序后,只需为其定义一个服务即可
# app/config/services.yml
services:
my_handler:
class: AppBundle\Monolog\YourApiHandler
并将其添加到独白配置中:
# app/config/config.yml
monolog:
handlers:
my_handler:
type: service
id: my_handler