1
1
Logging
2
2
=======
3
3
4
- Symfony comes with a minimalist `PSR-3 `_ logger: :class: `Symfony\\ Component\\ HttpKernel\\ Log\\ Logger `.
5
- In conformance with `the twelve-factor app methodology `_, it sends messages starting from the
4
+ Symfony comes with two minimalist `PSR-3 `_ loggers: :class: `Symfony\\ Component\\ HttpKernel\\ Log\\ Logger `
5
+ for the HTTP context and :class: `Symfony\\ Component\\ Console\\ Logger\\ ConsoleLogger ` for the
6
+ CLI context.
7
+ In conformance with `the twelve-factor app methodology `_, they send messages starting from the
6
8
``WARNING `` level to `stderr `_.
7
9
8
10
The minimal log level can be changed by setting the ``SHELL_VERBOSITY `` environment variable:
@@ -17,13 +19,18 @@ The minimal log level can be changed by setting the ``SHELL_VERBOSITY`` environm
17
19
========================= =================
18
20
19
21
The minimum log level, the default output and the log format can also be changed by
20
- passing the appropriate arguments to the constructor of :class: `Symfony\\ Component\\ HttpKernel\\ Log\\ Logger `.
21
- To do so, :ref: `override the "logger" service definition <service-psr4-loader >`.
22
+ passing the appropriate arguments to the constructor of :class: `Symfony\\ Component\\ HttpKernel\\ Log\\ Logger `
23
+ and :class: `Symfony\\ Component\\ Console\\ Logger\\ ConsoleLogger `.
24
+
25
+ The :class: `Symfony\\ Component\\ HttpKernel\\ Log\\ Logger ` class is available through the ``logger `` service.
26
+ To pass your configuration, you can :ref: `override the "logger" service definition <service-psr4-loader >`.
27
+
28
+ For more information about ``ConsoleLogger ``, see :doc: `/components/console/logger `.
22
29
23
30
Logging a Message
24
31
-----------------
25
32
26
- To log a message, inject the default logger in your controller or service::
33
+ To log a message using the `` logger `` service , inject the default logger in your controller or service::
27
34
28
35
use Psr\Log\LoggerInterface;
29
36
// ...
@@ -55,7 +62,7 @@ Adding placeholders to log messages is recommended because:
55
62
* It's better for security, because escaping can then be done by the
56
63
implementation in a context-aware fashion.
57
64
58
- The `` logger `` service has different methods for different logging levels/priorities.
65
+ The logger implementations has different methods for different logging levels/priorities.
59
66
See `LoggerInterface `_ for a list of all of the methods on the logger.
60
67
61
68
Monolog
0 commit comments