Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Python logging module defines these classes:</p> <p><strong>Loggers</strong> that emit log messages.<br/> <strong>Handlers</strong> that put those messages to a destination.<br/> <strong>Formatters</strong> that format log messages.<br/> <strong>Filters</strong> that filter log messages.<br/></p> <p>A <strong>Logger</strong> can have <strong>Handlers</strong>. You add them by invoking the <code>addHandler()</code> method. A <strong>Handler</strong> can have <strong>Filters</strong> and <strong>Formatters</strong>. You similarly add them by invoking the <code>addFilter()</code> and <code>setFormatter()</code> methods, respectively.</p> <p>It works like this:</p> <pre><code>import logging # make a logger main_logger = logging.getLogger("my logger") main_logger.setLevel(logging.INFO) # make some handlers console_handler = logging.StreamHandler() # by default, sys.stderr file_handler = logging.FileHandler("my_log_file.txt") # set logging levels console_handler.setLevel(logging.WARNING) file_handler.setLevel(logging.INFO) # add handlers to logger main_logger.addHandler(console_handler) main_logger.addHandler(file_handler) </code></pre> <p>Now, you can use this object like this:</p> <pre><code>main_logger.info("logged in the FILE") main_logger.warning("logged in the FILE and on the CONSOLE") </code></pre> <p>If you just run <code>python</code> on your machine, you can type the above code into the interactive console and you should see the output. The log file will get crated in your current directory, if you have permissions to create files in it.</p> <p>I hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload