monolog

Can Laravel 4 log to a MySQL database?

蓝咒 提交于 2019-12-04 08:36:30
问题 If so how can it be done? By default L4 writes to a text file. I notice that Monolog can Log to Database on its github page. 回答1: Yep, You could create a listener to log everything in the routes.php Event::listen('laravel.log', function($type,$message) { $log = new Log(); $log->message = $message; $log->type = $type; $log->update; }); Or alternatively if you wanted to only log errors 400 and 500 Larvavel there is a Log event in the Routes.php file which listens to errors 404 and 500, you can

Composer 入门后,接下来该看看这篇文章了

风格不统一 提交于 2019-12-04 00:28:36
上篇文章,我们了解了 Composer 的包是如何开发的,过程中我们使用了 composer init、 composer install、 composerrequire、 composer config 命令,还有哪些比较常用的命令呢? 常用命令 在使用 composer 时,我们要先对其更新版本,使用命令: //查看composer版本 composer -V //更新composer版本 composer self-update 创建项目,使用命令: //比如,创建 Laravel 项目 composer create-project --prefer-dist laravel/laravel blog 更新项目中所有的包或者指定的包,使用命令: //更新所有的包 composer update //更新指定的一个包 composer update monolog/monolog //更新指定的多个包 composer update monolog/monolog guzzlehttp/guzzle //更新通过匹配符匹配的包 composer update monolog/monolog guzzlehttp/* 删除项目中指定的包,使用命令: //删除指定的包 composer remove monolog/monolog 查询项目中指定的包,使用命令: /

How to log multiline entries with monolog like a formatted array?

风格不统一 提交于 2019-12-04 00:05:47
I am trying to log an array with monolog in symfony . $logger = $this->get('logger'); $logger->info(=print_R($user,true)); the output i get is not formatted as a print_r would be expected. It logs it all on one line. I do not have any monolog settings in my config.yml and suspect this may be the issue. How can I log a print_r(array) using monolog so it displays formatted in a tail -f ? Monolog uses Monolog\Formatter\LineFormatter by default without any arguments. Formatter is basically object that is responsible for final output in your logs. Look at constructor definition: public function _

Monolog, how to log PHP array into console?

丶灬走出姿态 提交于 2019-12-03 14:14:43
问题 I am using the browser handler to log message into JS console require_once 'vendor/autoload.php'; use Monolog\Logger; use Monolog\Handler\BrowserConsoleHandler; $log = new Logger('name'); $log->pushHandler(new BrowserConsoleHandler); $data = array(1,2,3,4); // add records to the log $log->addWarning('Foo'); I am wondering, is it possible to log array such as $data into the console which reassemble the array content? 回答1: Try this: $log->addWarning('Foo: ' . var_export($data, true)); 回答2: The

Laravel 5 different log levels for development and production

巧了我就是萌 提交于 2019-12-03 11:54:36
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 Emergency priority and ignore log requests with lower priority. I couldn't find anything in the documentation

Log rotating with Monolog in Symfony2

一世执手 提交于 2019-12-03 10:45:48
问题 I'd like to know if there's any possibility to configure Monolog in Symfony2 to create a new log file every day, for example : 2013-11-21-prod.log. 回答1: There is a logger called rotating_file . Here is a sample configuration: monolog: handlers: main: type: rotating_file path: %kernel.logs_dir%/%kernel.environment%.log level: debug 回答2: On linux, you can use logrotate (I don't know if exists other solutions on windows or macos) In /etc/logrotate.d/ create a file (eg. sf2_myapp) and add this

How to do advanced filtering of Monolog messages in Symfony?

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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

Symfony2 Monolog Settings for email and file logging

。_饼干妹妹 提交于 2019-12-03 04:22:21
I want to setup Symfony2 to send me an email for critical errors, but just log error level errors. Will the following settings do that? monolog: handlers: main: type: fingers_crossed action_level: error handler: grouped grouped: type: group members: [filelog, mail] # log all errors to file filelog: type: fingers_crossed action_level: error handler: nested_stream nested_stream: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug # send me an email when we have a critical error mail: type: fingers_crossed action_level: critical handler: buffered buffered: type: buffer

Laravel 5: laravel.log could not be opened: Permission Denied

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: To stop you from the start, there is NO permission issue. /storage is recursively chmodded 777 and whole project folder is chowned by apache:apache I even renamed the log file to ...-old and apache created a new one... if it didn't have actual write permissions it would not had been allowed to create it. Running under CentOS release 6.6 (Final) Deployed the project from git, the homestead works for my colleague. Full error: [Mon May 18 10:17:58 2015] [error] [client 86.124.208.14] PHP Fatal error: Uncaught exception 'UnexpectedValueException

Laravel daily log created with wrong permissions

匿名 (未验证) 提交于 2019-12-03 02:12:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a script that I run using php artisan (with root user), and sometimes it causes the daily log file to be created before the apache www-data user does - which means that when a real user uses my web application, I get the folder permission error: Failed to open stream: Permission denied I change the permissions back to www-data everytime but I want to solve this by having the log file always created with the correct permissions. I've considered creating a cron job that creates the file or touches it to make sure it has the