Log Level may or may not exist

Posted on Apr 23, 2022 at 11:48 PM
Using Unreal Engine, the logs may or may not have the log level in them.

For example, the following are all valid log entries in Unreal Engine

[2022.04.23-23.24.34:815][  0]LogWindows: DebugString: PrimaryIsNotTheChoosenAdapter PrimaryIsNotTheChoosenAdapter PrimaryIsNotTheChoosenAdapter GetVideoDriverDetailsInvalid PrimaryIsNotTheChoosenAdapter
[2022.04.23-23.24.38:686][  0]LogPython: Warning: 'xxxxxxxxx' and 'xxxxxx' have the same name (xxxxxxxxx) when exposed to Python. Rename one of them using 'ScriptName' meta-data. 
[2022.04.23-23.27.39:787][864]LogUObjectHash: Compacting FUObjectHashTables data took   1.54ms
[2022.04.23-23.27.43:549][977]SourceControl: fatal: unable to get credential storage lock in 1000 ms: No such file or directory


As you can see, the entries are fairly inconsistent. When doing my own log entries, I made sure to be a bit more consistent. However I cannot seem to come up with a good parser for the inconsistent Unreal (and plugins) logs. I would like the log level to be UNKNOWN when there is no log level found. Currently, because the parser expects a colon and does not find one in log entries without a log level, it combines log entries of 2 (or more) lines into one.

For example, in the following screenshot, because the log level does not exist in the message, the parser gets confused and merged 3 log entries into one.


Posted on Apr 24, 2022 at 12:32 PM
Hi Samaursa,

When parsing a log file, LogViewPlus requires all log entries to have the same format.  Optional fields are not supported.

However, you can use multiple parsing patterns.  This technique works best when the more complicated pattern is defined first and the appropriate pattern can be determined by looking at the first line. 

For example, if I use the pattern:

[%d{yyyy.MM.dd-HH.mm.ss:fff}][%3t]%c: %p: %m%n
[%d{yyyy.MM.dd-HH.mm.ss:fff}][%3t]%c: %m%n



You can see that the log level is set to NONE in line 3.



Hope that helps,

Toby
Posted on Apr 26, 2022 at 12:17 AM
Thank you Toby. The multiple parser pattern worked great!

This topic is closed and cannot receive new replies.