Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about log file name #1104

Open
xiaojinlii opened this issue Mar 21, 2024 · 1 comment
Open

about log file name #1104

xiaojinlii opened this issue Mar 21, 2024 · 1 comment
Labels
question Further information is requested

Comments

@xiaojinlii
Copy link

xiaojinlii commented Mar 21, 2024

loguru==0.7.2

my code:

log_path_info = os.path.join(log_path, f'info_{time.strftime("%Y-%m-%d")}.log')
info = logger.add(log_path_info, rotation="00:00", retention="30 days", enqueue=True, encoding="UTF-8", level="INFO")

I don't understand why there are two similar log file names on 20th and 21st

info_2024-03-19.2024-03-19_11-14-09_416342.log
info_2024-03-19.2024-03-20_14-09-11_097343.log
info_2024-03-19.2024-03-20_16-02-21_334324.log
info_2024-03-19.2024-03-21_09-56-09_383562.log
info_2024-03-19.2024-03-21_09-56-25_604816.log
info_2024-03-19.log
info_2024-03-21.log

I started multiple processes in fastapi, whether it has anything to do with multiple processes

@Delgan Delgan added the question Further information is requested label Mar 30, 2024
@Delgan
Copy link
Owner

Delgan commented Mar 30, 2024

This is likely due to FastAPI restarting the whole application each time a worker is spawned. This causes logger.add() to be called multiple times, and different files to be created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants