monolog

symfony 2.4 can't get the doctrine channel in prod environment

时间秒杀一切 提交于 2019-12-05 18:23:52
I can't manage to get a log of the doctrine channel in my prod environment. I'm using symfony/symfony v2.4.6 symfony/monolog-bundle v2.6.0 doctrine/common v2.4.2 Here is my monolog config in config_prod.yml : monolog: handlers: doctrine: bubble: false action_level: DEBUG type: stream path: "%kernel.logs_dir%/%kernel.environment%_doctrine.log" channels: doctrine security: bubble: false action_level: DEBUG type: stream path: "%kernel.logs_dir%/%kernel.environment%_security.log" channels: security request: bubble: false action_level: DEBUG type: stream path: "%kernel.logs_dir%/%kernel.environment

Send email when error occurs in console command of Symfony2 app

泪湿孤枕 提交于 2019-12-05 14:21:08
How is it possible to send email with log when something wrong in console command? Currently I've configured my app to send emails from web interface and it works correctly. Swiftmailer spool is disabled. My config is: monolog: handlers: main: type: fingers_crossed action_level: critical handler: grouped grouped: type: group members: [streamed, buffered] streamed: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug buffered: type: buffer handler: swift swift: type: swift_mailer from_email: info@site.com to_email: username@site.com subject: An Error Occurred! level:

How to do advanced filtering of Monolog messages in Symfony?

♀尐吖头ヾ 提交于 2019-12-05 01:34:31
I am using the MonologBundle in my Symfony 2.8 project to manage log messages. Using different Handlers it is no problem to write logs to file and to send them by e-mail at the same time. I would like to reduce the number of messages I receive by mail. I already use the DeduplicationHandler and the FingersCrossed handler to filter by error level and to avoid duplicate messages. This works fine but is not enough. For example I would like to reduce the number of mail about PageNotFound errors. Of course I want to be notified if /existingPage is not found, but I am not interested in messages

How to add data to all log records in Laravel?

守給你的承諾、 提交于 2019-12-04 23:42:14
问题 I would like to add some data to all log records within my Laravel application. I think it would be helpful to know the username of the current user and/or the client IP address. Currently I'm adding it manually by doing: Log::info('Pre-paid activation.', array('username' => Auth::user()->username)); But I would like to know how to do add a listener or something to make all log recorde have the username (if available). 回答1: Since Laravel comes out of box with Monolog, it is pretty straight

composer linux全局安装

十年热恋 提交于 2019-12-04 22:26:08
我把它放在系统的PATH目录中,这样就能在全局访问它。 curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer 注意:如果上诉命令因为权限执行失败, 请使用 sudo 再次尝试运行 mv那行命令。 输入命令:composer -V Composer version 1.0-dev (feefd51565bb8ead38e355b9e501685b5254d liuxiaoqiang@liuxiaoqiang /var/www $ sudo curl -sS https://getcomposer.org/installer | php [sudo] password for liuxiaoqiang: All settings correct for using Composer Downloading... Composer successfully installed to: /var/www/composer.phar Use it: php composer.phar liuxiaoqiang@liuxiaoqiang /var/www $ sudo mv composer.phar /usr/local/bin/composer

Graylog2 with Symfony 2 (Monolog)

╄→гoц情女王★ 提交于 2019-12-04 22:13:20
问题 I want to use the "Monolog -> GelfHandler" in a SF2 project. So I've added the following to my composer.json: "graylog2/gelf-php": "dev-master" My SF2 config.yml: monolog: handlers: main: type: gelf publisher: hostname: %Graylog2.Host% port: %Graylog2.Port% level: info formatter: monolog.formatter.session_request But now, if I want to log something, I get an error in GelfHandler::write() Gelf\Publisher::publish() must be an instance of Gelf\MessageInterface, string given What is wrong here?

Composer安装和使用

风格不统一 提交于 2019-12-04 18:18:53
Composer 是 PHP 的一个 依赖管理工具 。它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们。 Composer 不是一个包管理器。是的,它涉及 "packages" 和 "libraries",但它在每个项目的基础上进行管理, 在你项目的某个目录中(例如 vendor )进行安装 。默认情况下它不会在全局安装任何东西。因此,这仅仅是一个依赖管理。 对于使用者来说Composer非常的简单,通过简单的一条命令将需要的代码包下载到 vendor 目录下,然后开发者就可以引入包并使用了. 其中的关键在于你项目定义的 composer.json ,可以定义项目需要依赖的包(可能有多个),而依赖的包可能又依赖其他的包(这就是组件的好处),这些都不用你烦心,Composer会自动下载你需要的一切,一切在于 composer.json 的定义. 1、Composer的安装 方法一: 下载并且运行 Composer-Setup.exe ,它将安装最新版本的 Composer ,并设置好系统的环境变量,因此你可以在任何目录下直接使用 composer 命令( 这是将 Composer 安装在你机器上的最简单的方法,推荐使用。 ) 一直点下一步就安装成功了,这里的路径是自动加上的,如果没有就手动加上(注: 运行 Composer 需要 PHP 5.3.2+ 以上版本 )

How come log lines written by Monolog don't get messed/mixed up when two script instances are writing to log concurrently?

情到浓时终转凉″ 提交于 2019-12-04 17:44:43
When using Monolog with StreamHandler , it is normal situation that several instances of PHP script would be writing to the same log file in parallel. (eg. in my Symfony application, when mulitple users open "Login page" at the same time, it would result in multiple instances of my app script ( app.php ) running and thus two instances of Monolog StreamHandler would be writing into same app/logs/prod.log .) How come that despite of concurrent writing to the file, each log lines is not broken in the middle and messed up? How come the situation below never happens: instance1 of StreamHanler only

Symfony 2 : Log into a specific file

不想你离开。 提交于 2019-12-04 10:24:37
问题 I searched a lot before posting my question. I didn't find a clear answer, so here it is. I want to log messages in a different log file as dev.log or prod.log. I mean a file which won't be poluted by Symfony core messages. I heard about logger and handler in monolog, but it's not very clear. How can I log messages from my controllers, model to a specific log file ? 回答1: You have to add the info to the services.yml file, not the config.yml file: So in services.yml ( or services.xml ) you have

Why does Symfony still log to a dev.log file, even when I didn't define it in a loghandler?

风格不统一 提交于 2019-12-04 08:43:16
During the execution of Symfony Commands, I want to log messages to a different file. I have read the Symfony and Monolog documentation, and it should work like I describe here. (Note that I know messages from the 'doctrine', 'event', ... channels will still be logged by the main handler, but that doesn't matter for me) In my config.yml , I have this: monolog: channels: [commandline] handlers: main: type: stream path: "%kernel.logs_dir%/%kernel.environment%.main.log" level: debug channels: [!commandline] commandline: type: stream path: "%kernel.logs_dir%/%kernel.environment%.commandline.log"