We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

PSR-3 Logger support

As PSR-3 has become a Standard Recommendation, I would encourage you to implement it into the framework. This way we could use third-party logger libraries like Monolog.




Thanks for the recommendation, but Phalcon is a highly decoupled framework and our Logging component is not a dependency of other components, you can use Monolog or any other component for logging without problem,

For example, to log the database queries sent to the database server using Monolog:

$eventsManager = new Phalcon\Events\Manager();

$log = new Monolog\Logger('name');
$log->pushHandler(new Monolog\Handler\StreamHandler('logs/db.log', Logger::WARNING));

//Listen all the database events
$eventsManager->attach('db', function($event, $connection) use ($log) {
    if ($event->getType() == 'beforeQuery') {

//Assign the eventsManager to the db adapter instance

//Execute some SQL statement
    array("Hot pepper", 3.50),
    array("name", "price")

here is typo, should be $logger than $log please correct and remove my comment :)


thanks @doit76, corrected

thanks for the example @Phalcon I see the concept more clearer