Management of Log files

Hello everyone,
I have been working with log files and I have some questions regarding them.

  1. How do we prevent log files from frappe bench log directory from taking up too much space on the server?
    Is there a feature that tracks the size of existing log files and creates a new file as soon the current one is approaching the threshold size?

  2. I discovered Frappe.log is configured in the frappe/utils/logger.py file and limited to 100000 bytes maximum size. Please where can I find the script responsible for the other types:

  • worker.error.log
  • web.error.log
  • schedule.error.log
  • schedule.log
1 Like

I also looking for this feature.

Found out that the log file generated by gunicorn, python rq and schedule.

I think the rotating log function can be done outside frappe, e.g. by using logrotate

Yes, I used Log Rotate to manage the log files in the /tmp folder as well.

Found that we can add these parameter in supervisor.conf :
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10

2 Likes

I think you’ll need to follow up with these commands for the changes to take effect:

sudo supervisorctl reread
bench restart

Also noteworthy:
Add those two lines for every section you’d like to affect, e.g:


; graceful timeout should always be lower than stopwaitsecs to avoid orphan gunicorn workers.
[program:frappe-bench-frappe-web]
command=/home/frappe-u/frappe-bench/env/bin/gunicorn -b 127.0.0.1:8000 -w 5 --max-requests 5000 --max-requests-jitter 500 -t 6000 --graceful-timeout 30 frappe.app:application --preload
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/frappe-u/frappe-bench/logs/web.log
stderr_logfile=/home/frappe-u/frappe-bench/logs/web.error.log
stopwaitsecs=40
killasgroup=true
user=frappe-u
directory=/home/frappe-u/frappe-bench/sites
stdout_logfile_maxbytes=3MB
stdout_logfile_backups=5

[program:frappe-bench-frappe-schedule]
command=/home/frappe-u/.local/bin/bench schedule
priority=3
autostart=true
autorestart=true
stdout_logfile=/home/frappe-u/frappe-bench/logs/schedule.log
stderr_logfile=/home/frappe-u/frappe-bench/logs/schedule.error.log
user=frappe-u
directory=/home/frappe-u/frappe-bench
stdout_logfile_maxbytes=3MB
stdout_logfile_backups=5