随着时间的推移,Vaultwarden 日志文件会变得很大。使用 logrotate,我们可以定期轮换日志。

    1. sudo nano /etc/logrotate.d/bitwarden
    1. /var/log/bitwarden/*.log {
    2. # Perform logrotation as the bitwarden user and group
    3. su bitwarden bitwarden
    4. # Rotate daily
    5. daily
    6. # Rotate when the size is bigger than 5MB
    7. size 5M
    8. # Compress old log files
    9. compress
    10. # Keep 4 rotations of log files before removing or mailing to the address specified in a mail directive
    11. rotate 4
    12. # Truncate the original log file in place after creating a copy
    13. copytruncate
    14. # Don't panic if not found
    15. missingok
    16. # Don't rotate log if file is empty
    17. notifempty
    18. # Add date instaed of number to rotated log file
    19. dateext
    20. # Date format of dateext
    21. dateformat -%Y-%m-%d-%s
    22. }

    要在不手动解压缩的情况下查看压缩的日志文件:

    1. zcat logfile.gz
    2. zless logfile.gz
    3. zgrep -i keyword_search logfile.gz