Skip to content

Clarify the Logging situation #1036

@PJUllrich

Description

@PJUllrich

Problem Statement

Hey folks, now with the new TelemetryProcessor in place, I'm a bit confused as to whether we still need to add the :logger.add_handler/3 in the application. In the auto-setup for logs PR #998, you mention that manually adding the logger is no longer necessary but the docs don't clarify that yet.

I ran into this confusion because I've added new metadata to my log events and they show in my logs, but they don't show up in the Sentry logs UI (Discover > Logs > Click on a log row). Here's my setup:

I've recently upgraded to the latest 12.0.3 version and added the enable_logs: true flag and telemetry_processor_categories: [:log, :error, :check_in, :transaction] as described in the Changelog. I left my :logger.add_handler/3 in my application.ex because the Changelog did not specify that it needs removing. My Logger.error("foobar") calls still got logged in Sentry so all was well.

Now, I've added new metadata to my log events and they show up when I view my logs on my server, but they don't show in the Sentry Logs UI. I haven't had an error after making this change, so I can't tell whether the new metadata shows up in the regular Sentry error events.

In my application.ex, I have now:

def start(_type, _args) do
    :logger.add_handler(:sentry_error_log_handler, Sentry.LoggerHandler, %{
      config: %{metadata: :all, capture_log_messages: true, level: :error}
    })
   # ...
end
# config/prod.exs

config :sentry,
  dsn: "my-dsn",
  environment_name: Mix.env(),
  enable_source_code_context: true,
  root_source_code_paths: [File.cwd!()],
  enable_logs: true,
  telemetry_processor_categories: [:log, :error, :check_in, :transaction],
  integrations: [
    telemetry: [
      report_handler_failures: true
    ],
    oban: [
      capture_errors: true,
      cron: [enabled: true]
    ]
  ]

So, my questions are:

  1. Do we still need to add :logger.add_handler/3 if we add enable_logs: true to our Sentry config?
  2. If not, how do we configure the logs (e.g. level, metadata, capture_log_messages: true) and are the configuration options the same as for the Sentry.LoggerHandler?
  3. How can we still create Sentry Error events for Logger.error/1 calls but not for Logger.info/1 calls?

Solution Brainstorm

No response

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

Status

Waiting for: Product Owner

Relationships

None yet

Development

No branches or pull requests

Issue actions