Php 如何使用symfony2将日志消息存储到特定日志文件
我是symfony2新手,如何将日志消息存储到特定文件我阅读了文档,但不理解请帮助我配置的任何一个我的config.yml文件是:Php 如何使用symfony2将日志消息存储到特定日志文件,php,symfony,monolog,Php,Symfony,Monolog,我是symfony2新手,如何将日志消息存储到特定文件我阅读了文档,但不理解请帮助我配置的任何一个我的config.yml文件是: # app/config/config.yml monolog: handlers: filter_for_errors: type: fingers_crossed # if *one* log is error or higher, pass *all* to file_log action_level:
# app/config/config.yml
monolog:
handlers:
filter_for_errors:
type: fingers_crossed
# if *one* log is error or higher, pass *all* to file_log
action_level: error
handler: file_log
# now passed *all* logs, but only if one log is error or higher
file_log:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
# still passed *all* logs, and still only logs error or higher
syslog_handler:
type: syslog
level: error
和配置开发文件
# app/config/config_dev.yml
monolog:
handlers:
main:
type: rotating_file
path: '%kernel.logs_dir%/%kernel.environment%.log'
level: debug
# max number of log files to keep
# defaults to zero, which means infinite files
max_files: 10
如果我尝试使用存储日志消息
$logger = $this->get('logger');
$logger->info('I just got the logger');
这里将日志消息存储到dev.log文件,以及如何将日志消息存储到easyrecrue.log特定文件
感谢advance通常,您可以为特定的日志记录通道()创建处理程序,以将日志存储在不同的文件中 您还需要定义
Monolog捆绑包将以
Monolog.logger.\u channel%
格式为每个频道创建服务。如何将日志消息存储到easyrecrue.log特定文件中
-您能解释一下吗?如何将来自控制器、模型的消息记录到特定的日志文件中?我想存储easyrecrue.log文件,而不是dev.log文件谢谢回复,这里需要安装包吗?不,所有内容都在monolog bundle配置中,包含在symfony标准版中。