Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 1.02 KB

300-Logging.md

File metadata and controls

30 lines (19 loc) · 1.02 KB

There is no logging system built-in, but only a service that loads an instance of the Monolog\Logger class. In order to use this service run the following composer command:

composer require monolog/monolog

Without any configuration, the default logger writes log messages to the file logs/main.log file.

If you want to alter the default logger, you can specify this in a Log.php configuration file.

The logger from the above configuration file writes to the default log file, but also to php://stderr. Let's test it:

You may run this example:

php -S localhost:8000 -t examples/logging

If you visit e.g. http://localhost:8000

You will get a couple of log message in logs/main.log, and because we use the log instance from config/Log.php class the same messages are written to php://stderr.

For more information visit Monolog\Logger.