8000 Added information about injecting a logger to your service · symfony/symfony-docs@c8992e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8992e6

Browse files
committed
Added information about injecting a logger to your service
Reverted whitespace Fixed unclear sentence about the Monolog logger tag Fixed committed whitespace
1 parent 50c8385 commit c8992e6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

logging.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ option of your handler to ``rotating_file``:
308308
),
309309
));
310310
311+
Injecting a Logger into a Service
312+
----------------------------------
313+
314+
To use a logger in your own service, inject it using Dependency Injection
315+
with ``@logger``. If you want to use a pre-configured logger which uses a
316+
specific channel (``app`` by default), use the ``monolog.logger`` tag with the
317+
``channel`` property. Look at the :ref:`Dependency Injection reference
318+
<dic_tags-monolog>` for more information and an example.
319+
311320
Adding extra Data to each Log (e.g. a unique request token)
312321
-----------------------------------------------------------
313322

0 commit comments

Comments
 (0)
0