Skip to content

Logging to file and silencing liesel messages #163

Answered by jobrachem
jeli2103 asked this question in Q&A
Discussion options

You must be logged in to vote

You can basically remove the log handler that prints messages to the console. You can use a function like this:

import logging

def remove_first_liesel_log_handler():
    liesel_logger = logging.getLogger("liesel")
    liesel_stdout = liesel_logger.handlers[0]
    liesel_logger.removeHandler(liesel_stdout)

Then, to remove logging to the console and instead add a log handler that logs to a file, you can do the following:

from liesel.logging import add_file_handler

add_file_handler(path="your/logfile.log", level="info")
remove_first_liesel_log_handler()

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@jobrachem
Comment options

@jobrachem
Comment options

@jeli2103
Comment options

@jobrachem
Comment options

@jobrachem
Comment options

Answer selected by jeli2103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants