-
Hey Liesels, """python script"""
import logging
import liesel.model as lsl
import liesel.goose as gs
# loggers
logger_liesel = logging.getLogger('liesel')
logger_liesel.setLevel(logging.INFO)
logger_gr = logging.getLogger('groupie')
logger_gr.setLevel(logging.INFO)
# create file handler which logs to file
fh = logging.FileHandler('liesel_groupie.log')
fh.setLevel(logging.INFO)
# create formatter and add
formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
# add handler
logger_liesel.addHandler(fh)
logger_gr.addHandler(fh)
logger_gr.info('nothing is impossible')
# start liesel goose engine: engine.sample_all_epochs() In my case the file liesel_groupie.log looks good. The console, however, does not have 'nothing is impossible', but all liesel messages. How can I silence them as well? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
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() |
Beta Was this translation helpful? Give feedback.
You can basically remove the log handler that prints messages to the console. You can use a function like this:
Then, to remove logging to the console and instead add a log handler that logs to a file, you can do the following: