Skip to content
Advertisement

Python logging to stdout and log file

I am fairly new in python and starting to get into the logging module. I would like to have the message logged into a log file and outputting to the console. The code below prints out the message to console but how can I get all the message to be log in a file?

Logger object does not have a function call (basicConfig(filename=)) for logging to a file. How can I add this functionality?

Thanks for the help in advance.

JavaScript

Advertisement

Answer

You just need to add another handler, like a logging.FileHandler

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement