Python logging

The module for logging in python is called Logging… It is already present in python by default and does not require additional installations.

There are several types of errors:


From the names of the methods, you can understand what they are.

Their output can be customized in different ways. For example, add the following information in the file:

import logging

loggingbasicConfig(filename=“logs / info.log”, filemode=‘w’, level=loggingINFO, format=‘% (asctime) s | % (message) s’)

loggingbasicConfig(filename=“logs / error.log”, filemode=‘w’, level=loggingERROR)

Then, in those modules and methods where you want to add a logger:

import logging
logginginfo(f“No errors. | Name: {variable}”)

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *