# How to subscribe to/redirect log messages?

**URL:** <https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 18, 2016, 7:02am UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561 "2016-04-18T07:02:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![komorra](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@komorra](https://forums.unrealengine.com/u/komorra)\
**Post date:** [April 18, 2016, 7:02am UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561/1 "2016-04-18T07:02:02Z")

</div>

How to (in correct way) “hook” into UE4 logging system, to redirect log messages output to somewhere else? E.g. I have a custom module, which by I would to capture every UE\_LOG call message, for further purpose.

Which part of engine (source code) will be good place to change for such log message capture? What is the proper way (stable and side-effect resistant) to do this?

---

<div class="post-metadata">

**Author:** ![Cryptoxic](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cryptoxic](https://forums.unrealengine.com/u/Cryptoxic)\
**Post date:** [March 9, 2017, 3:41pm UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561/2 "2017-03-09T15:41:47Z")

</div>

I was looking for the same thing: FOutputDeviceRedirector::Get()-\>AddOutputDevice(…); should do the trick. You would need to implement your own [OutputDevice](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Misc/FOutputDevice/index.html)

---

<div class="post-metadata">

**Author:** ![rob422lou](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rob422lou/32/88719_2.png) [@rob422lou](https://forums.unrealengine.com/u/rob422lou)\
**Post date:** [November 8, 2018, 12:28am UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561/3 "2018-11-08T00:28:43Z")

</div>

I’m having trouble with this. I can’t seem to get it to redirect anywhere. Not to a different file or an FString. Any suggestions on how to make the FOutputDevice?

---

<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:** [November 8, 2018, 3:55am UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561/4 "2018-11-08T03:55:52Z")

</div>

You need to add FOutputDevice as base class, like you would do that with interface, Look at UConsole as a example

> **[UConsole](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/Engine/UConsole/)**
>
> A basic command line console that accepts most commands.

---

<div class="post-metadata">

**Author:** ![Steijn.Kistemake](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Steijn.Kistemake](https://forums.unrealengine.com/u/Steijn.Kistemake)\
**Post date:** [November 8, 2018, 6:58am UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561/5 "2018-11-08T06:58:08Z")

</div>

If you wanted to ‘redirect’ the output to a string you could do it as follows:

```
class StringOutputDevice : public FOutputDevice
{
public:
	StringOutputDevice()
	{
		check(GLog);
		GLog->AddOutputDevice(this);
	}

	~StringOutputDevice()
	{
		if (GLog != nullptr)
		{
			GLog->RemoveOutputDevice(this);
		}
	}

protected:
	virtual void Serialize(const TCHAR* Message, ELogVerbosity::Type Verbosity, const class FName& Category) override
	{
		MyString += Message;
	}

private:
	FString MyString;
};

```

Please note that the logs will still end up in the normal places as well. You are just adding an output device to which it will also be sent.

---

<div class="post-metadata">

**Author:** ![rob422lou](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rob422lou/32/88719_2.png) [@rob422lou](https://forums.unrealengine.com/u/rob422lou)\
**Post date:** [November 8, 2018, 1:09pm UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561/6 "2018-11-08T13:09:34Z")

</div>

I got it to work. Thanks for your help!

---

<div class="post-metadata">

**Author:** ![Blindopoly](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Blindopoly](https://forums.unrealengine.com/u/Blindopoly)\
**Post date:** [October 2, 2019, 4:04am UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561/7 "2019-10-02T04:04:57Z")

</div>

Can someone explain the full solution? I pretty much did what you posted here but it seems like my call to _GLog-\>AddOutputDevice(this);_ is not working. I made a post about it here

> **[How do I use the Device Output Log window?](https://forums.unrealengine.com/questions/926433/how-do-i-use-the-device-output-log-window.html)**
>
> Hi, my goal is to be able to log debug info for a specific feature in my game to my its output window. I know UE\_LOG logs messages but it logs them all to the same place so it gets cluttered. I saw there was a Device Out Log which looks like it lets...

---

<div class="post-metadata">

**Author:** ![Shen\_Yuju](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shen\_Yuju](https://forums.unrealengine.com/u/Shen_Yuju)\
**Post date:** [November 15, 2023, 8:30pm UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-redirect-log-messages/354561/8 "2023-11-15T20:30:31Z")

</div>

thanks alot for bringing up this question, and for UE5, it can be done in a very easy way:

```auto
FStringOutputDevice OutputDevice;
FOutputDeviceRedirector::Get()->AddOutputDevice(&OutputDevice);
// call the log functions
FOutputDeviceRedirector::Get()->RemoveOutputDevice(&OutputDevice);
UE_LOG(LogTemp, Display, TEXT("the captured log is: %s"), *OutputDevice);

```
