monolog

Monolog: how to catch all errors and exceptions

孤人 提交于 2021-02-08 15:27:11
问题 I'm missing something really obvious. How can I make monolog record all php errors, php user errors, and exceptions? Before using monolog, I wrote my own functions which I passed to set_error_handler() , register_shutdown_function() and set_exception_handler() . Is there a way of doing this using Monolog's API, or do I have to the following? Write an error handler and exception handler which I pass to PHP's functions above In those handlers, call the appropriate Monolog functions such as

Google Cloud Stackdriver and monolog Symfony

半城伤御伤魂 提交于 2021-01-28 09:16:43
问题 I'm working with Google Cloud (GKE) and I want to use their system for log and monitor (Stackdriver). My projet is under php Symfony3. I'm searching how to log to stackdriver some logs of my symfony project. I saw that there is an offical lib : https://github.com/GoogleCloudPlatform/google-cloud-php And a PSR-3 class : http://googlecloudplatform.github.io/google-cloud-php/#/docs/v0.20.1/logging/psrlogger My question is, how to integrate that in my config.yml with monolog ? 回答1: I did this by

monolog 应该是世界上最好的日志插件了

风格不统一 提交于 2021-01-08 05:54:55
引入 composer require monolog/monolog 官网 https://github.com/Seldaek/monolog 创建工具类 <?php /** * Created by PhpStorm. * User: jiqing * Date: 18-6-27 * Time: 上午11:19 */ require '../vendor/autoload.php'; use Monolog\Logger; use Monolog\Handler\StreamHandler; use Monolog\Processor\UidProcessor; use Monolog\Processor\ProcessIdProcessor; use Monolog\Formatter\LineFormatter; use Monolog\Formatter\JsonFormatter; class MyLog { public static function setLog($content = [],$msg = "msg",$level = Logger::NOTICE ,$name = "jq",$formatter = "line",$path = "/tmp/jq.log") { // create a log channel $log = new Logger(

monolog记录日志

强颜欢笑 提交于 2021-01-08 04:28:19
<?php require_once 'vendor/autoload.php'; use Monolog\Formatter\LineFormatter; use Monolog\Logger; use Monolog\Handler\StreamHandler; $dateFormat = "Y-m-d H:i:s"; $output = "[%datetime%] %channel%.%level_name%: %message% %context%\n"; // 输出格式 $formatter = new LineFormatter($output, $dateFormat); $stream = new StreamHandler(__DIR__.'/test.log', Logger::DEBUG); $stream->setFormatter($formatter); $logger = new Logger('sql'); $logger->pushHandler($stream); $logger->info('执行语句',['name'=>'hello','age'=>110]); // 执行语句对应 message context对应context sql对应的是channel 生成 按天的日志 require_once 'vendor/autoload

PHP: How to use monolog to log to console (php://out)?

放肆的年华 提交于 2020-12-28 05:51:05
问题 I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on SO. The example on Monolog's Github readme only shows how to use a file: <?php use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger:

PHP: How to use monolog to log to console (php://out)?

时光总嘲笑我的痴心妄想 提交于 2020-12-28 05:47:08
问题 I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on SO. The example on Monolog's Github readme only shows how to use a file: <?php use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger:

PHP: How to use monolog to log to console (php://out)?

荒凉一梦 提交于 2020-12-28 05:43:04
问题 I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on SO. The example on Monolog's Github readme only shows how to use a file: <?php use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger:

PHP: How to use monolog to log to console (php://out)?

[亡魂溺海] 提交于 2020-12-28 05:42:38
问题 I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on SO. The example on Monolog's Github readme only shows how to use a file: <?php use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger:

【Composer】PHP开发者必须了解!

本小妞迷上赌 提交于 2020-11-23 09:01:42
Composer是一个非常流行的PHP包依赖管理工具,已经取代PEAR包管理器,对于PHP开发者来说掌握Composer是必须的. 对于使用者来说Composer非常的简单,通过简单的一条命令将需要的代码包下载到vendor目录下,然后开发者就可以引入包并使用了. 其中的关键在于你项目定义的composer.json,可以定义项目需要依赖的包(可能有多个),而依赖的包可能又依赖其他的包(这就是组件的好处),这些都不用你烦心,Composer会自动下载你需要的一切,一切在于composer.json的定义. Composer对于使用者来说是很透明,但是其背后的理念还是需要了解一下的,其的诞生也不是偶然的,得益于Github的快速发展,PHP语言也越来越现代化,显得更高大上了. 更多PHP相关知识请关注我的专栏 PHP ​zhuanlan.zhihu.com 为了理解Composer,先大概了解下其结构: Composer的结构 Composer命令行工具: 这个理解就比较简单了,通过使用者定义的Composer.json去下载你需要的代码,假如只是简单的使用Composer,那么掌握一些具体命令就完全可以了 Autoloading代码加载器: 通过Composer,开发者可以通过多种方式去使用,而其中的关键在于PHP的命名空间概念,以及PSR-4标准的发展