Skip to main content Link Menu Expand (external link) Document Search Copy Copied



To help you learn more about what’s happening within your application, this Slim skeleton provides robust logging services that allow you to log messages to files, the system error log, and even to Slack to notify your entire team.

Under the hood, this project utilizes the Monolog library, which provides support for a variety of powerful log handlers.


The directory for all log files is: logs/

The default settings are stored in config/defaults.php, $settings['logger']


It’s recommended using the App\Factory\LoggerFactory class to create a custom logger for each context.

The LoggerFactory provides methods to generate a file- and console based logging output.

Inject the LoggerFactory instance and generate a specific logger as follows:


use App\Factory\LoggerFactory;
use Psr\Log\LoggerInterface;

final class Example
    private LoggerInterface $logger;
    // ...

    public function __construct(LoggerFactory $loggerFactory) {
        $this->logger = $loggerFactory
    // ...

Creating a file logger:

$this->logger = $loggerFactory->addFileHandler('my_log_file.log')->createInstance();

Creating a console logger:

$this->logger = $loggerFactory->addConsoleHandler()->createInstance();
$this->logger->info('Console test output');

Creating a file and console logger:

$this->logger = $loggerFactory
$this->logger->info('File and console output');

Read more