how to redirect logging to jupyter process output

16 views
Skip to first unread message

Jeff Zhang

unread,
Aug 2, 2017, 11:53:02 PM8/2/17
to Project Jupyter
I try to run the following command, I don't want to display the logging in cell, but want to display in the jupyter process output. Is there anyway I can do that ? Thanks


    import logging
    logger = logging.getLogger()
    logger.info("hello world")

MinRK

unread,
Aug 3, 2017, 8:26:06 AM8/3/17
to Project Jupyter

If you write to sys.__stderr__ instead of sys.stderr, it will go to the original process output.

import logging
import sys

logger = logging.getLogger('mylogger')
logger.addHandler(logging.StreamHandler(sys.__stderr__))
logger.setLevel(logging.INFO)
logger.info("check the terminal")

-Min

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/6850f864-02d0-4ada-9f79-611cfbf35811%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages