monolog

Monolog implementation with common class

霸气de小男生 提交于 2019-12-14 03:50:36
问题 I succeeded in implementing a Monolog logger for test purposes. And now I'm trying to use it in a project. This project doesn't use any MVC framework. I'm trying to write a common class file to wrap access to the Monolog instance. Common class file: File: app_log.php require 'autoload.php'; use Monolog\Logger; use Monolog\Handler\RotatingFileHandler; use Monolog\Processor\UidProcessor; use Monolog\Processor\WebProcessor; use Monolog\Processor\MemoryUsageProcessor; use Monolog\Processor

Monolog logs file for every session

一曲冷凌霜 提交于 2019-12-13 01:26:53
问题 I'm using symfony for a cron run application that runs every day I want to use monolog to write an info report that I can then email, so I'm looking for a way to separate the files by session id. Example: report: type: stream path: "%kernel.logs_dir%/%kernel.environment%-%sessionid%.log" level: info Can this be done? 回答1: You have to override the AppKernel : <?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel {

Setting json formatter in monolog

青春壹個敷衍的年華 提交于 2019-12-12 18:46:41
问题 How can the logs be set to json format in monolog .... $logger = new StreamHandler(__DIR__.'/my_app.log'); $logger->setFormatter( new JsonFormatter() ); $logger->pushHandler($logger); This doesn't seems to be correct as it shows error Call to undefined method Monolog\Logger::setFormatter() also I would like my log to be recorded like this: message{ a="something"; b="something else" } instead of: message{a="something";b="something else"} 来源: https://stackoverflow.com/questions/41505176/setting

How to create rotating log file with Laravel and Monlog

北城以北 提交于 2019-12-12 18:01:37
问题 I'm trying to create my own rotating log file in Laravel using Monolog, however, the file rotation is not working and I don't know why. I've created an artisan command that runs once per day, and keeps a log of it's activity. I want old versions of this file to be deleted after 2 days. In other words only the log of today's run, as well as yesterday's run should exist. At the beginning of my artisan command, I have the following code: $log = new Logger('MyCustomLog'); $log->pushHandler(new

MonologBundle FingerCrossedHandler: how to configure excluded_404s

此生再无相见时 提交于 2019-12-11 12:49:15
问题 I'm working on a Symfony 2.8.6 application and I tried to configure my Monolog as described here and here. This is my Monolog config (bundle version 2.11.1): monolog: handlers: main_critical: type: fingers_crossed action_level: error handler: grouped channels: ["!doctrine", "!event", "!php"] excluded_404s: - ^/ grouped: type: group members: [streamed, crash, buffered] streamed: type: rotating_file max_files: 10 path: "%kernel.logs_dir%/%kernel.environment%.log" level: notice crash: type:

how to disable security.info and security.debug in monolog symfony2 logging

蓝咒 提交于 2019-12-11 06:29:58
问题 I constantly am seeing a bunch of the following log: [2015-02-15 09:08:16] request.INFO: Matched route "AppMainBundle_daftar_toko_province" (parameters: "_controller": "App\MainBundle\Controller\ZHomepageController::daftarTokoAction", "provinceName": "DKI JAKARTA", "_route": "AppMainBundle_daftar_toko_province") [] [] [2015-02-15 09:08:16] security.INFO: Populated SecurityContext with an anonymous Token [] [] [2015-02-15 09:08:16] security.DEBUG: Write SecurityContext in the session [] [] in

Set minimum PHP error reporting in Monolog ErrorHandler

ⅰ亾dé卋堺 提交于 2019-12-11 04:48:48
问题 Just started using Monolog to log errors in my PHP project but I want to set the minimum error reporting setting to NOTICE and above. The code Im using right now use Monolog\ErrorHandler; $handler = new ErrorHandler($logger); $handler->registerErrorHandler([], false); $handler->registerExceptionHandler(); $handler->registerFatalHandler(); Which generates all errors including NOTICES. How can I set the equvalent to error_reporting(E_ALL & ~E_NOTICE); using Monolog 回答1: The ErrorHandler will

How to include the severity of a log in the e-mail subject?

旧城冷巷雨未停 提交于 2019-12-11 02:19:56
问题 I'm using Monolog with Symfony2 and have configured a logging environment where everything is logged to file, and above a certain threshold are e-mailed to me. My config is below. However, I have not been able to adjust the e-mail subject so that it changes based on the actual level of the log. The difference in response time, for say, a warning and a critical, would probably be different. Is there a way to do this? monolog: handlers: main: type: stream path: %kernel.logs_dir%/%kernel

Laravel Monolog. Log INFO level to separate file

此生再无相见时 提交于 2019-12-10 16:48:13
问题 How to specify a separate file for logging INFO level in Laravel 5.1 and monolog? 回答1: If you would like add another monolog handler, you may use the application's configureMonologUsing method. You should place a call to this method in bootstrap/app.php file right before the $app variable is returned: $app->configureMonologUsing(function($monolog) { $monolog->pushHandler(new StreamHandler('path/to/info.log', Logger::INFO, false)); // false value as third argument to disable bubbling up the

Laravel logging with Monolog\Handler\BrowserConsoleHandler

夙愿已清 提交于 2019-12-10 15:58:52
问题 How can Laravel 5 's logging be changed to Monolog\Handler\BrowserConsoleHandler ? What doesn't work in Laravel 5 but does work in a standalone PHP file: use Illuminate\Support\Facades\Log; use Monolog\Handler\BrowserConsoleHandler; use Monolog\Logger; // create a log channel $log = Log::getMonolog(); // $log = new Logger('Testlogger'); //doesn't make any difference $log->pushHandler(new BrowserConsoleHandler(\Psr\Log\LogLevel::INFO)); // add records to the log $log->addWarning('Foo'); $log-