Skip to content
Utveckling

What is Stack trace?

A list showing exactly where the code went wrong. The error message's family tree. A debugger's best friend.

A stack trace is the list that shows exactly where in the code something went wrong — step by step, in reverse. When a program crashes, it prints a kind of map of which parts of the code called each other all the way to the error. It is the error message's family tree: you see not just that it broke, but the whole chain that led there.

Imagine you lose your keys somewhere on the way home. A stack trace is like getting an exact list: "you left work, walked to the bus, changed at the station, and dropped them on the stairs." Instead of searching everywhere, you go straight to the stairs. In the same way, a stack trace points the developer directly to the line where it failed.

At the top of the list is usually what went wrong most recently, and at the bottom is where it all started. Being able to read a stack trace is one of the most basic superpowers in debugging.

Why is a stack trace important for your business?

The faster an error is found, the faster it can be fixed — and the less it costs in lost time and customers. A good stack trace shortens debugging from hours of guessing to minutes of targeted fixing.

That also means lower development costs for you. When logs save stack traces, the developer does not need to reproduce the problem blindly and can go straight to the cause.

Stack trace in practice

Say a customer reports: "the receipt is not sent after purchase." Without a trace, the developer would have to guess. But in the system log there is a stack trace pointing straight at the function that sends email, showing it tried to use an email address that was missing. The error becomes obvious and can be fixed the same day.

In practice, stack traces are therefore a natural part of all good logging — they are the first thing a developer looks at when something goes wrong in production.

Common questions about Stack trace

What does stack trace mean?

A stack trace is a list showing exactly where in the code an error occurred and which steps led there. It works as a map for quickly finding the cause of a crash.

How do you read a stack trace?

At the top is usually what went wrong most recently and at the bottom is where it started. The developer follows the chain to find the exact line where the error occurred.

Why is a stack trace useful?

It saves time by pointing straight at the problem instead of guessing. That makes debugging faster and cheaper.

Related terms

← Full glossary