This chapter will explain how Splitlog joins log file lines into Message instances and how it moves them through the message lifecycle. This is essential to understanding certain limitations of Splitlog that may not be immediately obvious.
Splitlog reads changes from the watched log files line by line, as they appear. However, in order to provide some useful information here, it may group multiple lines into a single Message and infer some additional metadata from them. This process is called “splitting the log” and is what originally gave Splitlog its name.
In order to be able to separate the random set of lines into Messages, Splitlog needs to understand the boundaries of each message, and therefore have a good understanding of the file format. This is where the biggest limitations of Splitlog come from:
This has multiple consequences:
In cases where the splitter understands the log file, it can infer various metadata from them. There are various kinds of metadata that Splitlog is able to infer, such as:
In case splitter can not infer any of these, it will try to provide some sensible defaults. If it couldn’t do even that, it will return null.
The most basic TailSplitter available is the SimpleTailSplitter and it is what you get when you obtain LogWatch through LogWatchBuilder without specifying any splitter implementation. This splitter:
The JBossServerLogTailSplitter is a bit more advanced and supports the default log file format of the JBoss Application Server. It will infer every possible metadata and properly parse exception stack traces. The following code snippet illustrates how to obtain it.
LogWatch watch = LogWatchBuilder.getDefault() .watchingFile(...) .buildWith(new JBossServerLogTailSplitter());
The TailSplitter interface is fairly simple and users are encouraged to implement it to make Splitlog understand their particular log file formats. Pseudo-generic implementations for Logback and other logging systems would be welcome as pull requests.
Think you spotted a mistake in this document? A typo? Factual inaccuracy? Make an edit. Think of the legions of grateful users!