logger option , where is the file? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: logger option , where is the file? (/thread-33436.html) |
logger option , where is the file? - korenron - Apr-25-2021 Hello , I notice in many examples there is a logger import loggin logger = logging.getLogger('localGATT') logger.setLevel(logging.DEBUG)but I don't see any referance to the file where can I find it ? or is it something I need to setup also ? - of so what to do ? will this do? logging.basicConfig(filename='app.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')and then in the file I will get all the debug data ? Thanks, RE: logger option , where is the file? - snippsat - Apr-25-2021 Look at this post for basic setup. I would advice to use Loguru Then all boilerplate code that no one can remember is gone. from loguru import logger logger.add("error.log", backtrace=True, diagnose=True) def add(x, y): try: return(x + y) except Exception as error: logger.exception('msg') if __name__ == '__main__': print(add(5, '50')) # Make error error.log
|