> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/on-premises/zh-cn/pei-zhi/overleaf-toolkit/logging.md).

# 日志记录

你可以使用 `bin/logs` 脚本来查看服务日志。

基本用法示例：

```bash
# 查看 web 服务日志
bin/logs web

# 显示帮助
bin/logs --help

# 一次查看多个服务的日志
bin/logs filestore docstore web clsi

# 跟踪日志输出（类似 tail -f）
bin/logs -f filestore docstore web clsi

# 限制打印的行数（默认 50 行）
bin/logs -n 50 web

# 显示所有日志行
bin/logs -n all web

# 将输出重定向到文件
bin/logs -n all web > web.log
```

你可以使用 `bin/logs` 用于查看以下服务日志的脚本： `clsi`, `contacts`, `docstore`, `document-updater`, `filestore`, `git-bridge`, `mongo`, `notifications`, `real-time`, `redis`, `spelling`, `tags`, `track-changes`, `web`, `web-api`, `history-v1`, `project-history`.

## 复制日志

请参阅原始文档：<https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/logging#copying-logs>

将日志文件从主 `sharelatex` 容器复制到本地计算机：

```bash
docker cp sharelatex:/var/log/overleaf/{service-name}.log {service-name}.log
```

## 持久化日志

Docker 容器是临时性的，这意味着容器运行期间在容器内创建的文件/目录（包括日志文件）如果容器被重新创建将会被丢弃（例如，在运行 `bin/up`时）。要在容器重建之间保留日志文件：

* 将环境变量 `OVERLEAF_LOG_PATH` 设置在 `config/overleaf.rc` Toolkit 使用的文件中。这里应为主机上的目录，该目录将绑定挂载到 `sharelatex` 容器内的日志目录。
* 更改后并运行 `bin/up -d`，日志文件将保留在主机上并可直接访问。

{% hint style="warning" %}
你必须将用于绑定挂载的主机日志目录的所有者设置为 `www-data` 用户（uid=33），并确保权限为 `drwxr-xr-x` (755).

示例：

```bash
chown 33:33 data/overleaf/logs
chmod 755 data/overleaf/logs
```

{% endhint %}


---

# 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://ayakaleaf-pro.ayaka.space/on-premises/zh-cn/pei-zhi/overleaf-toolkit/logging.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.
