Sam
Sam

Reputation: 467

Python enable logging for executable during run time

I've created a python module with logging library displaying information. Example of logging output would be...

2016-09-28 02:54:39,089 - INFO - dataServer - Listening for incoming connections...
2016-09-28 02:54:41,089 - INFO - dataServer - Listening for incoming connections...

I've used pyinstaller to generate an executable from the python module. I was wondering if there was a way to enable the logging to display on command prompt when the executable is executed from the command prompt. I know I log to a file but I want to be able to see the logging information in real time.

Upvotes: 0

Views: 1895

Answers (1)

Ankit Sahu
Ankit Sahu

Reputation: 387

You must have added a FileHandler to output the content to a file. Similarly to output the content to console add StreamHandler in this way sh = logging.StreamHandler(sys.stdout) and add this handler to logger by logger.addHandler(sh)

Hope this helps, cheers.

Upvotes: 1

Related Questions