Bryan Fok
Bryan Fok

Reputation: 3487

Python logging how do i it create empty log file?

How do I stop logging to create a log file when there is no log message? Currently, the logger has created an empty log when even no logging message to it. Use case is I created a FileHandler that only log error (by logger.error("I am error!")), but I don't want it to create a file when there is no error.

Upvotes: 4

Views: 707

Answers (1)

Open AI - Opting Out
Open AI - Opting Out

Reputation: 24153

The documentation says to pass delay=True to create the file on the first emit call.

Upvotes: 3

Related Questions