You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 28, 2019. It is now read-only.
Add default logging configuration when using Client.run
While it is possible to do this type of your set up yourself, it's
better for beginners to have logging automatically set up for them.
This has come up often in the help channel over the years. This also
provides an escape hatch to disable it.
*discord.py* logs errors and debug information via the :mod:`logging` python
10
-
module. It is strongly recommended that the logging module is
11
-
configured, as no errors or warnings will be output if it is not set up.
12
-
Configuration of the ``logging`` module can be as simple as::
11
+
module. In order to streamline this process, the library provides default configuration for the ``discord`` logger when using :meth:`Client.run`. It is strongly recommended that the logging module is configured, as no errors or warnings will be output if it is not set up.
12
+
13
+
The default logging configuration provided by the library will print to :data:`sys.stderr` using coloured output. You can configure it to send to a file instead by using one of the built-in :mod:`logging.handlers`, such as :class:`logging.FileHandler`.
14
+
15
+
This can be done by passing it through :meth:`Client.run`:
The optional ``level`` argument specifies what level of events to log
23
-
out and can be any of ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, and
24
-
``DEBUG`` and if not specified defaults to ``WARNING``.
44
+
This is recommended, especially at verbose levels such as ``DEBUG``, as there are a lot of events logged and it would clog the stderr of your program.
25
45
26
-
More advanced setups are possible with the :mod:`logging` module. For
27
-
example to write the logs to a file called ``discord.log`` instead of
28
-
outputting them to the console the following snippet can be used::
46
+
More advanced setups are possible with the :mod:`logging` module. The example below configures a rotating file handler that outputs DEBUG output for everything the library outputs, except for HTTP requests:
0 commit comments