A configurable java agent to log programs running on the JVM
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src Bug fix Apr 21, 2015
.gitignore first Jan 22, 2015
.travis.yml first Jan 22, 2015
LICENSE Update LICENSE Sep 11, 2015
README.md Update README.md Mar 17, 2017
pom.xml Bug fix Apr 21, 2015


org.brutusin:logging-instrumentation Build Status

This module is an extension of instrumentation module that defines an interceptor (LoggingInterceptor) aimed at logging executions of third-party code.

Table of Contents


For each execution of an instrumented method, the agent generates a file with the following information of the execution:

  • Source: Method instrumented
  • Start: Execution start date
  • Parameters: JSON Serialization (if possible) of the method arguments
  • Elapsed: Execution duration
  • Returned: JSON Serialization (if possible) of the method arguments/exceptions

Files are ordered according to their execution order, and grouped in folders by the execution thread. Root logging folder is passed as an interceptor parameter via the agent parameters.


Remark that project tests are run after a fat-agent-jar (jar-with-dependencies) is created, and the interceptor class name is passed as the agent options (see pom.xml line 91)

In this example the only instrumented methods are these of SimpleClass:

public static String sayHello(String name) {
    return "Hello " + name + ", you fool, I love youuu! " + joinTheJoyRide();

public static String joinTheJoyRide() {
    return "C'mon join the joyrideee!";

public static String sayGoodBye() {
    return "Goodbye to you, goodbye to broken hearts";

, being the relevant application code (LoggingInterceptorTest):


Causing the following three files being generated under ${java.io.tmpdir}/${project.artifactId}-tests (one per method execution):


with content:


#Source: public static java.lang.String org.brutusin.instrumentation.logging.SimpleClass.sayHello(java.lang.String)
#Start: Thu Jan 22 12:45:20 CET 2015
[ "world" ]
#Elapsed: 455 ms
"Hello world, you fool, I love youuu! C'mon join the joyrideee!"


#Source: public static java.lang.String org.brutusin.instrumentation.logging.SimpleClass.joinTheJoyRide()
#Start: Thu Jan 22 12:45:21 CET 2015
[ ]
#Elapsed: 5 ms
"C'mon join the joyrideee!"


#Source: public static java.lang.String org.brutusin.instrumentation.logging.SimpleClass.sayGoodBye()
#Start: Thu Jan 22 12:45:21 CET 2015
[ ]
#Elapsed: 21 ms
"Goodbye to you, goodbye to broken hearts"


This project is still under development but serves well as an example. The most important issue is the implementation of these LoggingInterceptorTest methods:

    public boolean interceptClass(String className, byte[] byteCode) {
        return className.endsWith("SimpleClass");

    public boolean interceptMethod(ClassNode cn, MethodNode mn) {
        return true;

making the module non-reusable. The idea to a future implementation is to load a configuration file from the root logging folder passed, for example a logging.json, defining the rules to be used by the interceptor to evaluate if a class or method is being instrumented.

Nevertheless and for the time being, you can create your own implementation based on this example.

Support, bugs and requests



Contributions are always welcome and greatly appreciated!


Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0