> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 日志

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

基本用法示例：

```bash theme={null}
# View the web service logs
bin/logs web

# Show help
bin/logs --help

# View logs for multiple services at once
bin/logs filestore docstore web clsi

# Follow log output (like tail -f)
bin/logs -f filestore docstore web clsi

# Limit the number of lines printed (default 50)
bin/logs -n 50 web

# Show all log lines
bin/logs -n all web

# Redirect output to a file
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](https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/logging#copying-logs)

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

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

## 持久化日志

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

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

<Warning>
  你必须将用于绑定挂载的宿主机日志目录的所有者设置为 `www-data` 用户（uid=33），并确保权限为 `drwxr-xr-x`（755）。

  示例：

  ```bash theme={null}
  chown 33:33 data/overleaf/logs
  chmod 755 data/overleaf/logs
  ```
</Warning>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.