Hi All,
I was trying to play with logging and understand.
One thing i noticed got my attention and would like to understand the reason for that. Can you help me on that.
Why are the log messages displayed ahead of print messages, though they are not coded in that specific sequence?
In this example, i was hoping the Set2 logs come after the print messages.
Please note that i am aware that "logging.basicConfig(level=logging.INFO)" will not take effect and that is what i was playing with.
I was trying to play with logging and understand.
One thing i noticed got my attention and would like to understand the reason for that. Can you help me on that.
Why are the log messages displayed ahead of print messages, though they are not coded in that specific sequence?
In this example, i was hoping the Set2 logs come after the print messages.
Please note that i am aware that "logging.basicConfig(level=logging.INFO)" will not take effect and that is what i was playing with.
import logging print("") logging.debug("Set1 : This is a debug message") logging.info("Set1 : This is a info message") logging.warning("Set1 : This is a warning message") logging.error("Set1 : This is a error message") logging.critical("Set1 : This is a critical message") print("The default serverity level is WARNING. So we have WARNING and above messages displayed") print("") print("Attempting to change the severity level to INFO") print("However, due to limitation on configuring the logger this will not take effect") logging.basicConfig(level=logging.INFO) print("") logging.debug("Set2 : This is a debug message") logging.info("Set2 : This is a info message") logging.warning("Set2 : This is a warning message") logging.error("Set2 : This is a error message") logging.critical("Set2 : This is a critical message")
WARNING:root:Set1 : This is a warning message ERROR:root:Set1 : This is a error message CRITICAL:root:Set1 : This is a critical message WARNING:root:Set2 : This is a warning message ERROR:root:Set2 : This is a error message CRITICAL:root:Set2 : This is a critical message The default serverity level is WARNING. So we have WARNING and above messages displayed Attempting to change the severity level to INFO However, due to limitation on configuring the logger this will not take effect