# How to print callstack into log?

**URL:** <https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [July 6, 2016, 4:00am UTC](https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084 "2016-07-06T04:00:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skylonxe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skylonxe](https://forums.unrealengine.com/u/Skylonxe)\
**Post date:** [July 6, 2016, 4:00am UTC](https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084/1 "2016-07-06T04:00:30Z")

</div>

Hey guys,

How can i print call stack into log ? In blueprint there is Stack Trace node but I can not call that directly in c++ because of linker errors.

What is the best way to print callstack in code ?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [July 6, 2016, 4:51am UTC](https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084/2 "2016-07-06T04:51:17Z")

</div>

Then look up source code how this node do it, it seems oyu need to get FFrame and from there call GetStackTrace()

[https://github.com/EpicGames/UnrealEngine/blob/ab237f46dc0eee40263acbacbe938312eb0dffbb/Engine/Source/Runtime/Engine/Private/KismetSystemLibrary.cpp#L30](https://github.com/EpicGames/UnrealEngine/blob/ab237f46dc0eee40263acbacbe938312eb0dffbb/Engine/Source/Runtime/Engine/Private/KismetSystemLibrary.cpp#L30)  
[https://github.com/EpicGames/UnrealEngine/blob/ab237f46dc0eee40263acbacbe938312eb0dffbb/Engine/Source/Runtime/CoreUObject/Private/UObject/ScriptCore.cpp#L414](https://github.com/EpicGames/UnrealEngine/blob/ab237f46dc0eee40263acbacbe938312eb0dffbb/Engine/Source/Runtime/CoreUObject/Private/UObject/ScriptCore.cpp#L414)

There also seem to be more global version which is static function:

> **[FFrame::GetScriptCallstack](https://docs.unrealengine.com/5.1/en-US/API/Runtime/CoreUObject/UObject/FFrame/GetScriptCallstack/)**
>
> This will return the StackTrace of the all script frames currently active

[https://github.com/EpicGames/UnrealEngine/blob/ab237f46dc0eee40263acbacbe938312eb0dffbb/Engine/Source/Runtime/CoreUObject/Private/UObject/ScriptCore.cpp#L318](https://github.com/EpicGames/UnrealEngine/blob/ab237f46dc0eee40263acbacbe938312eb0dffbb/Engine/Source/Runtime/CoreUObject/Private/UObject/ScriptCore.cpp#L318)

Note that this only give you VM that powers blueprints call stack not native CPU call stack

---

<div class="post-metadata">

**Author:** ![Skylonxe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skylonxe](https://forums.unrealengine.com/u/Skylonxe)\
**Post date:** [July 6, 2016, 4:54am UTC](https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084/3 "2016-07-06T04:54:30Z")

</div>

Yes, I know but I can’t belive there is not some simple function for that. But yeah, I am looking for CPU call stack, same stack which crash reporter shows.

---

<div class="post-metadata">

**Author:** ![Michael.Fortinbh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Michael.Fortinbh](https://forums.unrealengine.com/u/Michael.Fortinbh)\
**Post date:** [June 13, 2017, 2:21pm UTC](https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084/4 "2017-06-13T14:21:06Z")

</div>

Supposing the PDBs are loaded, you could look at / trace FWindwsPlatformStackWalk::StackWalkAndDump – for other platforms there are other classes, each implements StackWalkAndDump.

That’s what the crash reporter uses for the call stack.

---

<div class="post-metadata">

**Author:** ![L4g0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@L4g0](https://forums.unrealengine.com/u/L4g0)\
**Post date:** [April 2, 2018, 5:10pm UTC](https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084/5 "2018-04-02T17:10:53Z")

</div>

I found an easy way by actually causing a CallStack to happen by referencing a null pointer when the suspicious activity is believed to be happening. This, mixed with print logs helped me out. I used to do this when working with build scripts.

---

<div class="post-metadata">

**Author:** ![Squirrlz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Squirrlz](https://forums.unrealengine.com/u/Squirrlz)\
**Post date:** [November 29, 2018, 8:41pm UTC](https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084/6 "2018-11-29T20:41:58Z")

</div>

I know it’s 2 years late, but FDebug::DumpStackTraceToLog() will do exactly this.

---

<div class="post-metadata">

**Author:** ![DuneGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dunegames/32/538495_2.png) [@DuneGames](https://forums.unrealengine.com/u/DuneGames)\
**Post date:** [October 3, 2022, 2:22am UTC](https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084/7 "2022-10-03T02:22:39Z")

</div>

Even later, but to see Stack Trace in the log file, add this to the DefaultEngine.ini

```auto
[Kismet]
ScriptStackOnWarnings=true

```

---

<div class="post-metadata">

**Author:** ![mrVentures](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mrventures/32/979982_2.png) [@mrVentures](https://forums.unrealengine.com/u/mrVentures)\
**Post date:** [September 22, 2024, 7:13pm UTC](https://forums.unrealengine.com/t/how-to-print-callstack-into-log/363084/8 "2024-09-22T19:13:44Z")

</div>

Previously, you could do: UnrealEditor-Core!PrintScriptCallstack()

In the immediate window. But now you need to use the exact name of your product. You can find the core module within Visual Studio’s Modules window, if your game is Mario it might be:  
MarioEditor-Core!PrintScriptCallstack()
