def main(): dictLogConfig = { "version": 1, "handlers": { "fileHandler": { "class": "logging.FileHandler", "formatter": "myFormatter", "filename": "dict.log" } }, "loggers": { "Curso": { "handlers": ["fileHandler"], "level": "INFO", } }, "formatters": { "myFormatter": { "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s" } } } logging.config.dictConfig(dictLogConfig) logger = logging.getLogger("Curso") logger.info("Program started") result = otromod.add1(7, 8) logger.info("Done!")
def main(): logging.config.fileConfig('3-config.cfg') logger = logging.getLogger("Curso") logger.info("Program started") result = otromod.add1(7, 8) logger.info("Done!")
def main(): dictLogConfig = { "version":1, "handlers":{ "fileHandler":{ "class":"logging.FileHandler", "formatter":"myFormatter", "filename":"dict.log" } }, "loggers":{ "Curso":{ "handlers":["fileHandler"], "level":"INFO", } }, "formatters":{ "myFormatter":{ "format":"%(asctime)s - %(name)s - %(levelname)s - %(message)s" } } } logging.config.dictConfig(dictLogConfig) logger = logging.getLogger("Curso") logger.info("Program started") result = otromod.add1(7, 8) logger.info("Done!")
def main(): logger = logging.getLogger("Curso") logger.setLevel(logging.INFO) fh = logging.FileHandler("hardcoded.log") formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) logger.addHandler(fh) logger.info("Program started") result = otromod.add1(7, 8) logger.info("Done!")
def main(): logger = logging.getLogger("Curso") logger.setLevel(logging.INFO) fh = logging.FileHandler("hardcoded.log") formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") fh.setFormatter(formatter) logger.addHandler(fh) logger.info("Program started") result = otromod.add1(7, 8) logger.info("Done!")