We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to save errors to file

Hello, how to save caught error to file log.

catch (\Exception $e) { $this->flash->error($e->getMessage()); }

This is shown for users in UI, but I want to save this to log file.

Hi Andrew you can use the log service

catch (\Exception $e) {
    $this->flash->error($e->getMessage()); 
    $this->log->error($e->getMessage());
}

or even you can create your ouw flash service and auto log all messages

Can a logger handle details like "$arguments" ?

sure you can use placeholders like this

$this->log->error('Huoston we have a problem. Detail: {detail}. Arguments: {args}',
    [
        'detail' => $e->getMessage(),
        'args' => print_r($mixedVar, true)
    ]
);

Good luck