Loupe for Java

From day one Loupe has been focused on .NET - Over the years we’ve expanded our purview to anywhere you can use C#.

In discussions with our largest customers, we found that all had Java development in their shops as well as .NET. All recognized the importance of logging and monitoring, but most have observed that their Java teams were not satisfied with their current logging and error management options. Since these shops use Java to develop applications with a similar role and with similar telemetry needs, we want to make Loupe a great fit there too.

Finally, after nearly a year of development, we’ve shipped Loupe for Java! Like our .NET agents, it’s free, open source, and provides a single solution for logging, metrics, and telemetry.

It Started with a Port

To create a Loupe Agent for Java, we started with a code conversion from the Loupe Agent for .NET Core. This agent already has all of the Windows-specific elements removed. We purchased a code converter that did a surprisingly good job translating .NET to Java - right down to camel casing of methods and introduction of some custom classes to handle .NET Events which have no direct equivalent in Java.

Once we had the source code converted to Java, getting it to compile took months. Fundamental differences between the two platforms, such as .NET supporting unsigned numbers which Loupe uses heavily for serialization, required much of the code to be rewritten. This phase of the project presented us with some interesting challenges, like:

  • Read/Write Streams: .NET’s Stream class supports reading, writing, and position indication. Java uses separate InputStream and OutputStream and works hard to make it difficult to know the position of an OutputStream. We had to rewrite several areas and even add in double-buffering approaches in some cases to preserve functionality.
  • Events: .NET makes it easy to declare custom events on a class and use them to let one object instance react to changes in another. The closest analog in Java is IObservable, which is much more coarse and requires more code to implement correctly.
  • Reference and Output Parameters: Since Java is a pass by value language, output variables are possible (through the use of DTOs) but awkward to use.
  • Collections and Lists: Loupe uses standard .NET List and Dictionary objects extensively. Java tends towards enumerable types and discourages access by ordinal.

To expedite the project, we ruthlessly eliminated internal logic not required in Java. This extra code exists on the .NET side because the same set of libraries support read and write operations. Since the Java agent only needs to create session data files that are compatible with the .NET implementation, this simplified our task.

And Ends in a Rewrite

By the time we got the unit tests to pass we’d made significant revisions to the API. For example, Loupe uses .NET Events to handle several key features. To work in Java these had to be rewritten in a different design pattern.

As development continued, it became clear to us that this new product should be more than a simple conversion: it should behave as though written for Java from the start. This meant preferring Java Beans over statics, DTOs over pass-by-reference parameters, visitor objects over event handlers and more.

We decided that by the time we shipped version 1.0 of this agent, the public APIs would have achieved a Java native character. Internal implementation details may still feel different, but over time, we will make incremental revisions to enhance the native Java character of the Loupe agent.

With Integration with Java’s Logging Frameworks

Many Java frameworks and applications already directly use a logging system - either Log4j2 or Logback. For Loupe to be useful it has to capture data written to those frameworks. We’ve included support for these and other logging frameworks to maximize what you’ll get right out of the box with Loupe. For more details, see Java Logging Framework Support

Our Java team is also developing extensions for common Java frameworks and tooling, most notably Spring, Tomcat, and Hibernate. These will proliferate over time after the initial Loupe Agent for Java is complete. Since the Java Agent creates the same binary formatted files as our .NET Agent, our existing analytical features will be compatible with it.

How You can Get It

Like the rest of Loupe’s agents, the Loupe Agent for Java is licensed as Open Source and available on GitHub. It’s also available as a Maven package, which is the preferred way to incorporate it into your Java application.
For complete information on how to integrate it with your Java application, see our Developer’s Guide for Java.

Naturally, we provide full support for this Agent. Take advantage of Loupe’s excellent log and telemetry viewer for Java, all for free - get started with Loupe today!

Rock solid centralized logging

Unlimited applications, unlimited errors, scalable from solo startup to enterprise.