1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] logging file is always empty

Discussão em 'Python' iniciado por Stack, Novembro 30, 2025.

  1. Stack

    Stack Membro Participativo

    Here is a snippet of how logging is done in my test script:

    logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s %(message)s",
    datefmt="%Y%m%d %H:%M:%S",
    handlers=[
    logging.FileHandler(args.log_file),
    logging.StreamHandler()
    ]
    )
    logger = logging.getLogger()
    Path(args.log_file).chmod(0o644)
    logger.info("this_is_a_test")


    When the testcase is finished running, the log file is created, but there is nothing in it:

    -rw-r--r-- 1 root root 0 Nov 30 12:50 /u/qiang/logs/mytest/01_test_with_simulator/001_TestWithSimulator.test_happy_path/simulator.log


    Not sure what's wrong in the code?

    Continue reading...

Compartilhe esta Página