【Hinemos Monitoring】Monitoring the StackTrace of Java using Logfile Monitor
This time, we will talk about Logfile monitoring.
As the name suggests, Logfile Monitor is a feature that allows you to monitor the logfile generated by any application.
Today’s objective will be monitoring a Java Stack Trace with the Logfile Monitor feature.
First, let’s review the Logfile Monitor feature!
What is Logfile Monitor?
This feature allows you to filter the log output of any given file inside of a monitored node. It will also notify you when the output log satisfies a specific matching condition.
Logfile Monitor also allows you to monitor the logs of any given application, for which you can get a notification when a specific log is generated.
Basically, all you have to do is set from the File Information tab, from which “Directory”, which “Filename (Regular Expression)” you want to monitor.
However, if you run the monitor without setting the file delimiters, the monitor will recognize the whole instance as one unique log.
Therefore, in order to analyze correctly a Java Stack Trace log for example (which often contains multiple lines of exceptions), it is necessary to set the desired log length.
Now, we will monitor the following logs.
2020-02-18 11:33:08.754 WARNING [StackTraceTest formatInt] java.lang.NumberFormatException: For input string: "0.1"
java.lang.NumberFormatException: For input string: "0.1"
※The log output is made so that the date and time is displayed at the beginning.
Although the logs content is concise, we can see that the exception “NumberFormatException” is generated after passing the decimal number “0.1” (INT type).
Let’s monitor our exceptions. Also, I think it will be interesting to check the differences between the 2 file delimiters below.
Now, in order to obtain the correct format (“yyyy-MM-dd hh:mm:ss.fff”) for the log output, we will set this part as the prefix pattern.
The prefix pattern should contain the following regular expression:
Below, you can find the outcome obtained for each monitoring setting.
① “Event details” (left image) and “Detailed message (Original message)” (right image)
② “Event details” (left image) and “Detailed message (Original message)” (right image)
As we can see from the detailed message, when using the return code LF delimiter (LF stands for Line Feed) only one line of code is being evaluated.
On the other hand, in the case you would use the prefix pattern delimiter, the whole Stack Trace is being evaluated hence displayed.
We used Hinemos to monitor a StackTrace this time, but Hinemos is also capable to monitoring logs including multiple lines by setting the output pattern as shown in this article.
Thank you for reading!