O'Reilly logo

Drupal 8 Module Development by Daniel Sipos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Our own logger channel

I mentioned earlier how we can define our own logger channel so that we don't have to always inject the entire factory. So, let's take a look at how to create one for the Hello World module we're now writing.

Most of the time, all we have to do is add the following definition to our hello_world.services.yml file:

 hello_world.logger.channel.hello_world:    parent: logger.channel_base    arguments: ['hello_world']

Before talking about the actual logger channel, let's see what this weird service definition actually means because this is not something we've seen before--I mean, where's the class?

The parent key means that our service will inherit the definition from another service. In our case, the parent key is logger.channel_base ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required