Skip to content

Conversation

@DaniilShomin
Copy link
Contributor

Добавлена настройка для вывода логов в консоль.

Copy link

@maxjamchuk maxjamchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отличная идея добавить единый конфиг логирования. Перед мержем необходимо исправить замечания с лейблами CAUTION и WARNING (disable_existing_loggers=True). Остальные комментарии — рекомендательные.

app/settings.py Outdated
# Logging
LOGGING = {
"version": 1,
"disable_existing_loggers": True,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

"disable_existing_loggers": True — это часто ломает/глушит логи Django и сторонних библиотек (в т.ч. django.request, django.server), потому что “существующие логгеры” отключаются, если их явно не описать в конфиге.

Рекомендация: либо поставить False, либо добавить явные секции loggers для django, django.request, etc., чтобы не потерять важные сообщения/стектрейсы.

},
"handlers": {
"console": {
"class": "logging.StreamHandler",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

handler logging.StreamHandler по умолчанию пишет в stderr. В контейнерах обычно ожидают stdout. Можно явно задать stream: "ext://sys.stdout" (или оставить как есть, если в проекте принято stderr).

"disable_existing_loggers": True,
"formatters": {
"default": {
"format": "[{asctime}] #{levelname:8} {name}:{lineno}:{funcName} - {message}",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

форматтер сейчас очень “шумный” ({lineno}:{funcName}) и при DEBUG=True будет много логов. Это ок для дев-режима, но в проде обычно выбирают уровень INFO (а не WARNING), плюс отдельные правила для django.request (например, 4xx/5xx). Можно подумать над более “продуктовым” дефолтом уровня/логгеров.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

пересмотреть disable_existing_loggers=True, чтобы не потерять системные логи Django/библиотек.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants