In this series of posts I am covering some of the many ways you can benefit from XpoLog and especially on how to get the most valuable information about your log4j event logs.

By running XpoLog Analytic Search on your log4j data, you can, among other things, measure your application performance and thread activity, measure code activity with class and method analytics on log4j, build security analysis, and make use of various visualization gadgets for maximum analysis.

In this post I will show you how XpoLog can help you find errors in your Java code, which in turn will help you create better quality code. You can download our software for free here.


We are using the same Java application as in my previous post, With Great Availability Comes Great Performance – one that runs various types of processes and uses log4j to log its activities. One of these logs is called errors, and it notes all the errors found in each of the classes of the code.

We will now see the benefits of the parsing process we did earlier. Quick re-cap:

In my post where I described how to define log4j Patterns in SysLog, I showed you that XpoLog has an advanced built-in mechanism to detect the structure, or pattern, of the incoming log. But as a user, you can edit and fine-tune these patterns to suit your needs.

You can create a detailed conversion pattern while adding your log4j log in XpoLog Center, setting the pattern to reflect the layout you defined in the log4j configuration. For the sake of our use case, we made sure to parse our log error to include separate columns for the Priority (ERROR, in our case) and the Class.

Screen Shot 2016-01-12 at 17.39.54

Investigating the Quality of the Code

We now want to check which classes in the code of our application wrote the most errors. By locating these errors quickly, we can create high quality code significantly faster. We do this by looking into the log error.

For a general view, we want to see the number of errors over a time span of 4 hours, just to make sure there are not too many.

In XpoLog Center, on the Search page, in the search field, type:

priority = error in log.errors | count | interval 1 hour  

Since the log may also include anomalies that are fatal, we specifically search for the anomalies that are “just” errors.

We get the following result:

Screen Shot 2016-01-12 at 17.40.30

We see the errors are spread fairly evenly during this time and do not jump (spike) during specific times. 

We now want to see which classes are responsible for the majority of the errors.

In XpoLog Center, on the Search page, in the search field, type:

priority = error in log.errors | count | group by class | order by count desc 

We get the following result:

Screen Shot 2016-01-12 at 17.41.16

We see that the class with the highest number of errors is

We would like to have a closer look at this class, and XpoLog gives you a very easy way to drill down into this particular class (or any other class on the list for that matter). All you need to do is click on the link (in the table) to

Once you click on the class, XpoLog will automatically change the search-query in the Search field by adding this class to the query with the action Add to search (AND). The search field will now read as follows:

(priority=errorAND IN log.errors  

We get the following (drill down) result:

Screen Shot 2016-01-12 at 17.42.03

We can now investigate the actual errors specifically found in the class

Perfect code is seldom found, but our quest for exceptionally high quality code has now been given a powerful boost.

In my next post I will show you how to view all of what we have found in XpoLog Apps. I will show you how to create Apps, Dashboards and Gadgets to better visualize all your data. Stay tuned for my next post or go directly to “Getting the Maximum from your log4j logs”.

One Small Error in Java Code, One Giant Leap for Java Code Quality

| Java Language| 848 views | 0 Comments
About The Author

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>