Where does Discourse store and show logs?

When troubleshooting issues or errors with Discourse it is important you look at your logs. Here’s a listing of where they are and what’s in there.

Your site domain

Administration logs shown in the UI

The Discourse admin panel contains several forms of logging:

The Logster web UI

Every Discourse instance ships with a GUI log viewer. It is located at: https://=DOMAIN=/logs

Note: if you are on a hosted plan, this page may be hidden from you. Instead, contact support when you’re getting this kind of issue!

If you’re investigating a mysterious 500 error on the forums, you should always try this spot first!

Select an error line to get details about it. You may be asked to provide the contents of the env and backtrace tabs here on Meta.

The Rails / Pitchfork logs

Ruby on Rails contains a very verbose log which is written to disk. Additionally the web server pitchfork (a fork of unicorn) also logs to disk.

To access:

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

This folder contains "production.log" and "unicorn.stderr.log" in addition to "rotated" log files. You can use standard Unix tools such as less production.log to inspect them.

This folder is also available without entering the container as /var/discourse/shared/standalone/log/rails.

The NGINX logs

Occasionally NGINX logs may contain some extra tips, they are located at:

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

The files access.log and error.log will be there as well as a bunch of rotated compressed files. Running less access.log.2.gz will automatically decompress and display the logfile for you.

This directory is also available on the host at /var/discourse/shared/standalone/log/var-log/nginx .

Redis logs

While it is very uncommon to need to see Redis logs, if you do need them, they go into /var/log/redis inside the container and /var/discourse/shared/standalone/log/var-log/redis on the host. The most recent log entries will be in the current file in that directory.

PostgreSQL logs

If you need to consult the database server logs, they’re in /var/log/postgres inside the container and /var/discourse/shared/standalone/log/var-log/postgres on the host; the most recent entries are in the current file in that directory.

Last edited by @JammyDodger 2024-05-25T11:27:33Z

Check documentPerform check on document:
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 лайка

Я также обнаружил, что этот лог полезен:

./launcher logs app

Это показывает любые ошибки в процессе сборки, если вы не знаете, к какому приложению обращаться.

7 лайков

У меня нет папки postgres в /var/log/postgres или /var/discourse/shared/standalone/log/var-log/postgres. Нужно ли мне выполнить какую-то настройку для генерации логов базы данных?

1 лайк

Если вы используете установку в 2 контейнерах или внешний PostgreSQL, то логи будут отсутствовать.

Для установки в 2 контейнерах логи должны находиться в
/var/discourse/shared/data/log/var-log/postgres

Для внешнего PostgreSQL ваши логи должны быть у провайдера управляемой базы данных.

4 лайка

Когда плагин вызывает сбой во время пересборки, где находятся логи, показывающие конкретную ошибку внутри плагина?

1 лайк

Они находятся в терминальном окне, где вы запускали пересборку. Если в вашем терминале недостаточно истории вывода, вам придется следить за процессом пересборки (или воспользоваться поиском в Google, чтобы узнать, как увеличить размер буфера прокрутки, или перенаправить вывод в файл, который можно будет найти позже).

1 лайк

Кажется, что плейсхолдер не работает в списке.

1 лайк

Я пытаюсь разобраться, какие из этих логов содержат персональные данные и как долго они хранятся. Похоже на следующее:

  • Логи электронной почты хранятся по умолчанию 90 дней
  • Логи Rails содержат IP-адреса и циклически перезаписываются (rotated) каждые 7 дней (из * logrotate.d)
  • Для NGINX действуют те же правила
  • Логи сотрудников/проверки (Staff/Screening) могут содержать персональные данные и хранятся бессрочно

Не упустил ли я что-то?

Могут ли логи ошибок (discourse.example.com/logs) также содержать персональные данные? Если да, то применяются ли к ним циклическая перезапись?

Могут ли логи контейнеров содержать персональную информацию? (например, ./launcher logs app и т. д.) Предполагаю, что их нужно вручную настроить на циклическую перезапись через Docker.