Discourse 在哪里存储和显示日志?

在对 Discourse 的问题或错误进行故障排除时,查看日志非常重要。以下是日志的位置及其包含的内容列表。

您的网站域名

在 UI 中显示的管理员日志

Discourse 管理面板包含多种日志记录形式:

Logster Web UI

每个 Discourse 实例都附带一个图形界面日志查看器。它位于:https://=DOMAIN=/logs

注意:如果您使用的是托管套餐,此页面可能会对您隐藏。如果是这种情况,请在遇到此类问题时联系支持人员!

如果您在论坛上遇到神秘的 500 错误,应始终首先尝试此位置!

选择错误行以获取有关它的详细信息。您可能需要在此处(Meta 站点)提供 envbacktrace 选项卡的内容。

Rails / Pitchfork 日志

Ruby on Rails 包含一个非常详细的日志文件,写入磁盘。此外,Web 服务器 pitchfork(unicorn 的一个分支)也会向磁盘写入日志。

访问方式:

cd /var/discourse
./launcher enter app
cd /shared/log/rails

此文件夹包含“production.log”和“unicorn.stderr.log”以及“已轮转”的日志文件。您可以使用标准的 Unix 工具,例如 less production.log 来检查它们。

该文件夹也可在不进入容器的情况下通过 /var/discourse/shared/standalone/log/rails 访问。

NGINX 日志

有时 NGINX 日志可能会包含一些额外提示,它们位于:

cd /var/discourse
./launcher enter app
cd /var/log/nginx

access.logerror.log 文件以及一堆已轮转的压缩文件都在那里。运行 less access.log.2.gz 将自动解压缩并显示日志文件。

此目录也可在宿主机上通过 /var/discourse/shared/standalone/log/var-log/nginx 访问。

Redis 日志

虽然很少需要查看 Redis 日志,但如果您需要,它们会进入容器内的 /var/log/redis 和宿主机上的 /var/discourse/shared/standalone/log/var-log/redis。最新的日志条目在目录中的 current 文件里。

PostgreSQL 日志

如果您需要查看数据库服务器日志,它们位于容器内的 /var/log/postgres 和宿主机上的 /var/discourse/shared/standalone/log/var-log/postgres;最新的条目在该目录中的 current 文件里。

46 个赞

Is there any option/console in admin ui to run these command and get logs in web? I do not see any option.

2 个赞

I have also found this log to be useful:

./launcher logs app

This shows any errors during the build process if you don’t know which app to look at.

7 个赞

I don’t have a postgres folder in /var/log/postgres or /var/discourse/shared/standalone/log/var-log/postgres. Is there some configuration I need to make to generate DB logs?

1 个赞

If You’re using a 2 container install or external postgres, then the logs will not be there.

For 2 container install, the logs should be in the
/var/discourse/shared/data/log/var-log/postgres

For external postgres, your logs should be with the managed db provider.

4 个赞

当插件导致重建失败时,显示插件内具体错误的日志文件存储在哪里?

1 个赞

他们住在你运行重建的终端窗口中。如果你的终端滚动回看不够,那么你必须在重建过程中注意(或者搜索如何增加回滚,或者将输出管道传输到你可以稍后找到的地方)。

1 个赞

占位符在列表中似乎不起作用

1 个赞

我正试图弄清楚这些日志中哪些包含个人数据以及保留多长时间。看起来:

  • 电子邮件日志默认保留 90 天
  • Rails 日志包含 IP 地址,并在 7 天后轮换(来自 \* logrotate.d
  • NGINX 也是如此
  • 员工/筛选(Staff/Screening)可能包含个人数据并永久保留

我是否遗漏了什么?

错误日志(discourse.example.com/logs)是否也可能包含个人数据?如果是,它们会被轮换吗?
容器日志是否可能包含个人信息?(即 \\./launcher logs app\` 等)我猜这些需要通过 Docker 手动配置进行轮换。