Delgan / loguru

Python logging made (stupidly) simple
MIT License
20.04k stars 702 forks source link

两个脚本写进同一个日志文件,同一条日志会写入两遍 #1204

Open Acheng97 opened 2 months ago

Acheng97 commented 2 months ago

只有a脚本调用b脚本,把a中创建的日志文件当作参数传入b脚本,才不会出现同一条日志写入两遍的情况

Delgan commented 2 months ago

Both scripts are written to the same log file, and the same log is written twice. Only if script a calls script b and passes the log file created in a as a parameter to script b, will the same log not be written twice

Hi.

You likely need to call logger.remove() first. Also, make sure logger.add() is only called once (to be put inside a if __name__ == "__main__" block for example).