B
B
bubaley2021-08-10 18:10:13
Django
bubaley, 2021-08-10 18:10:13

How to correctly log data through loguru in django with docker?

Hello, I have a question about logging data inside a container.
In django I use the loguru library to implement this functionality with the following settings

logger.add(f'{BASE_DIR}/logs/today.log',
           rotation='00:00',
           compression='tar.gz',
           format='{time:YYYY-MM-DD HH:mm} | {level} | {message} | {file.path}:{function}')

But when I go to the server in the logs folder and try to look at the logs, today several files are generated and then they are archived. Also, not all records get into the log, which is strange (maybe the necessary records fly into the archives, but I'm not sure how it works)
6112969d2c6b0282907716.jpeg
If you look, then on some days there are several daily logs. Maybe I need to forward the log folder somehow, but I don’t know how to do it.

How can I make the logging work correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergeykons, 2021-08-12
@bubaley

This is probably not the most correct approach in terms of Best Practices.
Docker advises container logs to be sent to STDOUT and STDERR. Then through docker logs you can see them all. In addition, using the mechanisms of the docker itself or then send kubernetes to any centralized storage
https://docs.docker.com/config/containers/logging/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question