Error Handling & Logging
From Tomahawk 2.0.0 it ships with a
which is used for catching and logging errors as well as rendering responses for 404
and all 50x errors.
Creating Error Templates
app/Resources/ErrorHandlerBundle/views there are 3 templates:
You can create a template with the name errorXXX.php for a specific HTTP Status Code.
If a template doesn't exist for a specific HTTP Status code then exception.twig will be used.
Tomahawk uses Monolog for logging errors. It has quite a simple setup.
app/config there will be a file called
Tomahawk allows you to use either the
Custom Logging Handler
You can write your own handler by implementing
Monolog\Handler\HandlerInterface, adding the handler to the
service container and adding it to the logging config as follows:
Using the Logger
The easiest way to use the logger is to just add the following parameter to the construct method of your
Psr\Log\LoggerInterface and it will get injected in through the Service Container.
You can also get into out of the container by doing