I wonder what is the differences between two versions below? And how to use it effectively?
Version 1:
import logging
logging.info("Hello world!")
Version 2:
import logging
logger = logging.getLogger(__name__)
logger.info("Hello world!")
I run my code:
class TestBedLog():
async def test(self):
import logging
logging.info("Log from logging")
logger = logging.getLogger(__name__)
logger.info("Log from logger")
And the result is:
root: INFO: Log from logging
src.myserver.test.test_apiv2.test_bedlog: INFO: Log from logger
As you can see, logging is from the root. And logger you will see the file where log the information
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With