> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-pro.ayaka.space/on-premises/zh-tw/she-ding/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 使用的檔案中。這應該是主機上將會以 bind mount 掛載到內部日誌目錄的目錄 `sharelatex` 容器中。
* 變更此設定並執行 `bin/up -d`後，日誌檔將會持久保存於主機上，並可直接存取。

{% hint style="warning" %}
您必須將用於 bind mount 的主機日誌目錄擁有者設為 `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://overleaf-pro.ayaka.space/on-premises/zh-tw/she-ding/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.
