monolog

How not to show last bracket in a monolog log line?

你离开我真会死。 提交于 2019-11-30 00:29:08
问题 // in my PHP code $log = new Logger('LaurentCommand'); $log->pushHandler(new StreamHandler('./app/logs/LaurentCommand.log')); $log->addInfo("Start command",array('username' => 'Joe', 'Age' => '28')); Result in log file LaurentCommand.log : [2012-12-20 10:28:11] LaurentCommand.INFO: Start command {"username":"Joe","Age":"28"} [] Why this bracket at the end ? 回答1: That's the extra data. The default format of the LineFormatter is "[%datetime%] %channel%.%level_name%: %message% %context% %extra%

Laravel 5 different log levels for development and production

微笑、不失礼 提交于 2019-11-29 17:48:05
问题 I'm using Laravel 5.1 and trying to set different logging logic for a development and production environment. Throughout my application I am using the Log facade with most of the following different methods: Log::emergency($error); Log::alert($error); Log::critical($error); Log::error($error); Log::warning($error); Log::notice($error); Log::info($error); Log::debug($error); However, in my production environment, I would like to only log anything that is an Error , Critical , Alert or

Custom monolog handler for default monolog in Symfony 2

喜夏-厌秋 提交于 2019-11-29 05:56:24
问题 I want to add a custom handler to a default monolog in Symfony 2. In my config.yaml file, I have: monolog: handlers: main: type: stream path: %kernel.logs_dir%/%kernel.environment%.log level: debug myHandler: type: Acme\MyBundle\Monolog\MyCustomHandler level: error My class looks like below: // Acme\MyBundle\Monolog\MyCustomHandler use Monolog\Logger; use Monolog\Handler\SocketHandler; use Monolog\Formatter\LineFormatter; class MyCustomHandler extends AbstractProcessingHandler { ... } But

Composer 常用命令总结(三)

孤街醉人 提交于 2019-11-29 00:56:55
init(初始化) 该命令用于创建 composer.json 文件,并进行基础信息配置: $ composer init 可以配置Package name、Description、Author、Minimum、Package Type、License、dependencies 及 dev dependencies 信息。 完成后配置文件内容如下: { "name": "test/test", "description": "test init", "type": "library", "license": "License Description", "authors": [ { "name": "mayanlong", "email": "json_vip@163.com" } ], "require": {} } search(搜索) 根据名称搜索相关的包,成功后会列出符合的相关包的信息,本处以搜索 monolog 为例: $ composer search monolog monolog/monolog Sends your logs to files, sockets, inboxes, databases and various web services kdyby/monolog Integration of Monolog into Nette Framework

php composer使用

若如初见. 提交于 2019-11-28 11:54:06
Composer-PHP中用来管理依赖(dependency) 定义 composer是PHP中用来管理依赖(dependency)关系的工具。你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer会帮你安装这些依赖的库文件。 Composer 需要PHP5.3.2+ 以上的环境来运行。有几个敏感的PHP设置和编译标志也是必需的,但安装程序会发出警告当存在任何不兼容的情况。 Composer 是兼容多平台的,其运行适用于Windows,Linux和OSX。 安装 linux curl -sS https://getcomposer.org/installer | PHP 你可以通过 --install-dir 选项指定 Composer 的安装目录(它可以是一个绝对或相对路径) 全局安装 mv composer.phar /usr/local/bin/composer 现在只需要运行 composer 命令就可以使用 Composer 而不需要输入 php composer.phar。 windows 下载 https://getcomposer.org/Composer-Setup.exe windows可能需要设置composer的环境变量 composer -V 查看版本号 composer -help 查看命令帮助 参考文献 http:/

PHP Composer

孤街浪徒 提交于 2019-11-28 11:53:37
Composer 是 PHP5.3以上 的一个依赖管理工具。它允许你声明项目所依赖的代码库,它会在你的项目中为你安装他们。Composer 不是一个包管理器。是的,它涉及 "packages" 和 "libraries",但它在每个项目的基础上进行管理,在你项目的某个目录中(例如 vendor)进行安装。默认情况下它不会在全局安装任何东西。因此,这仅仅是一个依赖管理。 Composer是PHP中用来管理依赖(dependency)关系的工具。你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer会帮你安装这些依赖的库文件。 使用 假定你在创建一个项目,你的项目中需要一个输出日志的库,而且你决定使用monolog库。 为了将monolog库添加到你的工程,只需创建 composer.json 文件,这个文件中的内容描述了项目的依赖关系。示例如下:{ "require": { "monolog/monolog": "1.2.*" }} 这行简单文字声明了被依赖的库 -- monolog,版本为1.2。 1 { 2 "name":"glow/model-test", 3 "require":{ 4 "monolog/monolog":"1.0.*" 5 } 6 } 使用中国镜像 { "require": { "monolog/monolog": "1.2.*"

Laravel : How to Log INFO to separate file

谁说我不能喝 提交于 2019-11-28 06:44:05
How to specify a separate file for logging INFO in Laravel 5.1 ? Any immediate help will be highly appreciable. Thanks Do you want to specifically log info to one log file and another log type to another location? My solution might not help in that case, but could still be useful. To write a log file to another location, use the method useDailyFiles or useFiles , and then info to log to the log file at the path you just specified. Like so: Log::useDailyFiles(storage_path().'/logs/name-of-log.log'); Log::info([info to log]); The first parameter for both methods is the path of the log file

How to write logs from one service into separate file?

六月ゝ 毕业季﹏ 提交于 2019-11-27 17:12:25
Normally you just get logger service, and logs go to: %kernel.root_dir%/%kernel.environment%.log I would like to log messages form SOAP services ONLY to: %kernel.root_dir%/%kernel.environment%.soap.log not to main logfile. I've read the cookbook, but I don't understand how to configure monolog. Any help, clues? The MonologBundle logs everything using the same handlers for the whole framework. That means if one of your services needs to log to different handlers, you should create your own Logger/Handler and inject that in your service. This could be an example config (in yaml): services: my

Laravel : How to Log INFO to separate file

非 Y 不嫁゛ 提交于 2019-11-27 01:27:35
问题 How to specify a separate file for logging INFO in Laravel 5.1 ? Any immediate help will be highly appreciable. Thanks 回答1: Do you want to specifically log info to one log file and another log type to another location? My solution might not help in that case, but could still be useful. To write a log file to another location, use the method useDailyFiles or useFiles , and then info to log to the log file at the path you just specified. Like so: Log::useDailyFiles(storage_path().'/logs/name-of

How to write logs from one service into separate file?

柔情痞子 提交于 2019-11-26 18:56:20
问题 Normally you just get logger service, and logs go to: %kernel.root_dir%/%kernel.environment%.log I would like to log messages form SOAP services ONLY to: %kernel.root_dir%/%kernel.environment%.soap.log not to main logfile. I've read the cookbook, but I don't understand how to configure monolog. Any help, clues? 回答1: The MonologBundle logs everything using the same handlers for the whole framework. That means if one of your services needs to log to different handlers, you should create your