> ## 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`。這應該是主機上的一個目錄，會以 bind mount 方式掛載到 `sharelatex` 容器內的日誌目錄。
* 變更此設定並執行 `bin/up -d` 後，日誌檔就會持久保存在主機上，並可直接存取。

<Warning>
  您必須將用於 bind mount 的主機日誌目錄擁有者設為 `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.