in my python project i have several lines that are logging with debug level and other with info level. Now, when i run my code i can set at the begging the log level to info or debug level and that will log to a file and on the screen only the info or both info/debug messages accordingly.
How can i achieve to set to log to file always debug level but on screen always info level?
Example (only a small part):
loggername = 'Main.Case.' self.logger = logging.getLogger(loggername) self.logger.info('case() - Started') self.logger.debug('System ready...') self.logger.debug('File ready...') self.logger.debug('Memory ready...') self.logger.info('case() - Ready') This would print with info level only (on screen and log file):
Main.Case.case() - Started Main.Case.case() - Ready With debug level i will get (on screen and log file):
Main.Case.case() - Started Main.Case.System ready... Main.Case.File ready... Main.Case.Memory ready... Main.Case.case() - Ready I actually would like to have on screen always only the info level lines and in the log file info/debug level!
When i activate debug level then i will get everything to both out puts (screen/file).
Any one any idea??
Thanks in adv.
setLevelto set the logger toDEBUGand the handlers toINFOorDEBUG. Besides the docs, there are lots of examples.