Python logging basicConfig
Description: In Computing, a log file is a file that records either events that occur in an operating system, other software runs or message between different users of a communication software. logging is the act of keeping a log.
Many operating systems, software frameworks and programs include a Logging System.
Log Message can contain a variable data which can be date, time or variable's value. logging is an in-built module in Python. It is a flexible framework for emitting log message from python program.
basicConfig: It is a function that takes some keyword arguments. List of parameters are given below. This function does basic configuration by creating a streamhandler(sends logging output to streams such as sys.stdout, sys.stderr or any file-like object) with default formatter and adding it to the root logger.
Code:
import logginglogging.basicConfig(filename="basic.log",filemode='a',level=logging.INFO,format="%(asctime)s:%(levelname)s:%(message)s",datefmt="%a, %d %b %Y %H:%M:%S ")
After executing this code, basic.log file generated in same directory where python file is saved.
Name | Views | Likes |
---|---|---|
Python logging log | 356 | 0 |
Python logging getChild | 1030 | 0 |
Python logging config | 378 | 0 |
Python logging getLogger | 403 | 0 |
Python logging getLevelName | 539 | 0 |
Python Restaurant Management | 559 | 1 |
Python logging info | 514 | 0 |
Python logging makeLogRecord | 556 | 0 |
Python logging getLoggerClass | 466 | 0 |
Python logging getEffectiveLevel | 364 | 0 |
Python logging setLoggerClass | 772 | 0 |
Python logging Logger | 311 | 0 |
Python logging LogRecord | 853 | 0 |
Python logging Introduction | 301 | 0 |
Python logging Filter | 965 | 0 |
Python logging Two Different Files with logging | 2790 | 0 |
Python logging LoggerAdapter | 823 | 0 |
Python logging isEnabledFor | 634 | 0 |
Python logging debug warning error | 270 | 0 |
Python logging basicConfig | 512 | 0 |
Python logging Formatter | 712 | 0 |
Python logging FileHandler | 737 | 0 |
Python logging StreamHandler | 410 | 0 |
Python logging exception | 311 | 0 |
Python logging hasHandlers | 661 | 0 |
Python logging addLevelName | 679 | 0 |
Python logging disable | 1925 | 0 |
Comments