x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to subscribe to/redirect log messages?

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?

Product Version: Not Selected
Tags:
more ▼

asked Apr 18 '16 at 07:02 AM in C++ Programming

avatar image

komorra
16 1 2 4

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I was looking for the same thing: FOutputDeviceRedirector::Get()->AddOutputDevice(...); should do the trick. You would need to implement your own OutputDevice

more ▼

answered Mar 09 '17 at 03:41 PM

avatar image

Cryptoxic
6 1 3

avatar image rob422lou Nov 08 '18 at 12:28 AM

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?

avatar image Shadowriver Nov 08 '18 at 03:55 AM

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

https://api.unrealengine.com/INT/API/Runtime/Engine/Engine/UConsole/index.html

avatar image Steijn.Kistemake Nov 08 '18 at 06:58 AM

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.

avatar image rob422lou Nov 08 '18 at 01:09 PM

I got it to work. Thanks for your help!

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question