> For the complete documentation index, see [llms.txt](https://rs.ppgg.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rs.ppgg.in/other-information/logrotate-example.md).

# 5.转储示例

{% hint style="success" %}
对应的[官方页面地址](https://github.com/dani-garcia/vaultwarden/wiki/Logrotate-example)
{% endhint %}

随着时间增长，Vaultwarden 日志文件的大小可能会增长到很大。使用 logrotate，我们可以定期转储日志。

```shell
sudo nano /etc/logrotate.d/vaultwarden
```

```systemd
/var/log/vaultwarden/*.log {
    # 以 vaultwarden 用户和群组的身份执行转储
    su vaultwarden vaultwarden
    # 每天转储
    daily
    # 当大小大于 5M 时转储
    size 5M
    # 压缩旧的日志文件
    compress
    # 在删除或邮寄到 mail 指令中指定的地址之前，保留 4 个转储的日志文件
    rotate 4
    # 把当前日志备份并截断
    copytruncate
    # 如果日志文件不存在，继续下一个操作
    missingok
    # 如果日志文件为空则不进行转储
    notifempty
    # 在转储的日志文件中添加数字格式的日期
    dateext
    # dateext 的日期格式
    dateformat -%Y-%m-%d-%s
}
```

无需手动解压缩而查看压缩的日志文件：

```sh
zcat logfile.gz
zless logfile.gz
zgrep -i keyword_search logfile.gz
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://rs.ppgg.in/other-information/logrotate-example.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
