with

with

Hi,

I have a worker GenServer posting some results to its manager GenServer. The result is rather long and may contain hundreds of items. In some cases, this causes the manager GenServer to crash, however, I’m unable to see the stacktrace, because it gets truncated because of function argument size.

Here’s a shortened example:

02:17:00.222 [error] GenServer #PID<0.2821.0> terminating
** (stop) exited in: GenServer.call(Manager, {:post_results, %{data: ["2001167", "20011
68", "2001172", "2001169", "2001173", "2001176", "2001174", "2001175", "2001170", "20
01171", "2001178", "2001177", "2001196", "2001187", "2001188", "2001189", "2000489", "2001191", "2001192", "2001193", "2001194", "2001841", "202047
2", "2006815", "2019619", "2019942", "2020265", "2020588", "2019611", "201 (truncated)

This makes debugging the crashes very difficult. Is there a way to prevent the logs from truncating the crash data? Is there an alternative way of debugging such crashes?

Thank you!

Showing Posts 1 to 4

NobbZ

NobbZ

You can set the :truncate option to an appropriate value:

:truncate - the maximum message size to be logged (in bytes). Defaults to 8192 bytes. Note this configuration is approximate. Truncated messages will have " (truncated)" at the end. The atom :infinity can be passed to disable this behavior.

with

with OP

Unfortunately, the truncate setting has no effect, I’ve already tried that. Here’s my logger config:

config :logger,
  backends: [
    :console,
    {LoggerFileBackend, :error},
  ]
config :logger, :error,
  path: "/home/me/logs/scraper/error.log",
  level: :error,
  handle_otp_reports: true,
  handle_sasl_reports: true,
  truncate: :infinity

config :logger, :console,
  handle_otp_reports: true,
  handle_sasl_reports: true,
  level: :debug,
  truncate: :infinity

Both console, and the file have the log messages truncated.

Am I perhaps missing something?

50kudos

50kudos

I have exact same need (to see which file and line blows up), my solution is inspecting inside terminate/2 callback.

# You will know it when you need it
def terminate({_, trace}, _socket) do
  IO.inspect(trace, label: "terminate trace")
end

It will show file and line number without data log.

mindok

mindok

Saved me hours. Thanks!

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews