How to disable logging to console?
Closed this issue · 3 comments
By default, logger_tt logs to file and console same time.
How to disable logging to console and leave only logging to file?
Just open or create your own log_config.json
file.
Then in the root
logger's handlers, remove the console
handler.
Just open or create your own
log_config.json
file. Then in theroot
logger's handlers, remove theconsole
handler.
Is it possible to do it viscount custom config? Just in disable handler in python code?
Yes, you can do it the hard way.
Fork this repo, add the parameter to setup_logging
.
This parameter tells logger_tt to remove any handler that outputs a log to the console.
In this case, this is the console
handler of the root logger.
But in general, you have to search every logger for every handler and check that its stream
is stdout
before removing it.
Or the easy way.
The best practice for config loggers is to do it from a config file, not in the code.
logger_tt
was designed following that practice so that minimal code is needed to config the logging.
What you are trying to do is equivalent to creating a new logger from scratch with its own handler that logs only to file.
The log_config
file already does 99.99% of that job for you.
That means all you need to do is, copy/create your own version of the log_config
file with minor changes to fit your need, and nothing changed in the code.