跳到主要内容

在 ONLYOFFICE 文档中启用调试日志

概述​

在某些情况下,需要以调试模式运行 ONLYOFFICE 文档,例如,解决性能问题、检查日志或为支持收集信息。

有两种方式可以在调试模式下启动 ONLYOFFICE 文档。

选项 1. 使用环境变量(仅限 Docker)​

如果您通过 Docker 或 Docker Compose 管理 ONLYOFFICE 文档容器,建议使用环境变量来启用调试日志级别:

Docker​

  1. 使用 docker run 设置环境变量:

    docker run -i -t -d -p 8080:80 \
    -e DS_LOG_LEVEL=DEBUG \
    onlyoffice/documentserver-de:latest
  2. 如果容器已经在运行,请重启容器:

    docker restart <container>
  3. 可以通过以下命令查看日志:

    docker logs -f <container>

Docker Compose​

  1. 在运行容器时,在 docker-compose.yml 中设置环境变量:

    services:
    documentserver:
    image: onlyoffice/documentserver-de:latest
    container_name: documentserver
    restart: always
    environment:
    - DS_LOG_LEVEL=DEBUG
    ports:
    - "8080:80"
  2. 启动 Docker Compose:

    docker-compose up -d
  3. 如果容器已经在运行,请重启容器:

    docker-compose restart documentserver
  4. 可以通过以下命令查看日志:

    docker-compose logs -f documentserver

选项 2. 使用 log4js 配置文件​

要在调试模式下启动 ONLYOFFICE 文档:

  1. 打开 log4js 配置文件。文件路径取决于您使用的操作系统:

    • 对于 Windows - C:\Program Files\ONLYOFFICE\DocumentServer\config\log4js\production.json
    • 对于 Linux - /etc/onlyoffice/documentserver/log4js/production.json
    • 对于 Docker - /etc/onlyoffice/documentserver/log4js/production.json (在 Docker 容器内)
  2. 参考以下代码块

    {
    "categories": {
    "default": {
    "appenders": [
    "default"
    ],
    "level": "WARN"
    }
    }
    }
  3. 将 level 值从 "WARN" 更改为 "DEBUG"。

  4. 保存对 production.json 配置文件的更改。

  5. 执行以下命令应用更改:

    Linux

    systemctl restart ds-*

    Docker

    supervisorctl restart all

    或者重启 Windows 上的 ONLYOFFICE DocumentServer Proxy 服务:

    net stop DsProxySvc
    net start DsProxySvc
    net stop DsConverterSvc
    net start DsConverterSvc
    net stop DsDocServiceSvc
    net start DsDocServiceSvc
  6. 日志存储在以下位置(取决于安装类型):

    • 对于 Windows - C:\Program Files\ONLYOFFICE\DocumentServer\Log
    • 对于 Linux - /var/log/onlyoffice/documentserver
    • 对于 Docker - /var/log/onlyoffice/documentserver (在 Docker 容器内)和 /app/onlyoffice/DocumentServer/logs/documentserver(如果您挂载了卷,在主机上)