Custom Log Formats

Nikolay Kuznetsov edited this page Aug 8, 2017 · 3 revisions

Starting with Ideolog 0.3.0, users can specify custom formats for log files. This is done in Log Highlighting settings, available in Settings dialog under "Editor".

Ideolog comes with three example formats for Rider backend logs (aka "Pipe-separated"), IDEA logs and TeamCity build logs.

Specifying a custom log format

In order to make Ideolog aware of your log format in order to use per-field highlighting features, including time highlighting, you need to provide it with two Java regular expressions and one time format.

The "Message pattern" specifies how to parse a single message in log. It should include capture groups for time, severity, category and message. If your log format doesn't have one of these, it's safe to omit them. If your log has any additional fields, such as thread ID, it's also safe to include them as capture groups. Category and severity are used to improve "Go To Source" functionality. Time is used for time highlighting. This pattern is applied only to visible log lines, so it may be somewhat bulky and slow. In this pattern, '.' also matches newline by default. This is done for ease of matching multi-line messages.

The "Message start pattern" should match lines on which a message starts. It's applied to each line in the log file, and it has to be extremely fast in order to avoid performance issues. Also make sure to include "^" at the beginning, otherwise multi-line messages might match improperly.

The "Time format" specifies how to parse time for time highlighting.

In addition, you must specify capture group indices for time, severity and category. Capture groups are numbered starting with 1. If you don't have a capture group for an item, specify 0.

Log format detection

In order to detect the format of a log file, all existing patterns are matched against first 25 lines of a file. The one with most matches gets selected, if the amount of matches is above 5. Otherwise, a dumb per-line parser is used.

Because of this, it's recommended to make your patterns as specific as possible. Problems could also arise if your log format starts with lots of unformatted lines. If that is bothering you, feel free to create an issue.

Known issues

Right now, there is practically no pattern validation performed. Log formats with invalid patterns are simply ignored. In future versions, more user-friendly interface will be added, possibly with support for previews.

You may need to close and reopen a log file after changing log format settings.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.