I am repeating myself over and over again:
Dev's rule number 1 (one) : Man pages are the programmer's best friend
Everything you need to know is right here in Symfony Docs, the section you are interested in follows:
Configuring the Listener/Subscriber
Now that the class is created, you just need to register it as a service and notify Symfony that it is a "listener" on the kernel.exception event by using a special "tag": YAML
# app/config/config.yml
services:
kernel.listener.your_listener_name:
class: Acme\DemoBundle\EventListener\AcmeExceptionListener
tags:
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException }