Skip to content

Commit

Permalink
add README.txt and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kreyssel committed Mar 11, 2011
1 parent db778c0 commit 2a54045
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions javaagent/README.txt
@@ -0,0 +1,17 @@
Example of how to create a generic Logging Agent with Java Intrumentation API and Javassist
===========================================================================================

In many situations is it helpful to add logging functions to running code.

In this example we use the Java Intrumentation API and Javassist to add the
logging functionality at runtime. For this feature we manipulate the bytecode
for any class at runtime and add java.util.logging code for any class method.

This maven project packages all classes (incl. javassist) in a "fat jar".
This jar you can use directly to add it to the java command line:

java -javaagent:loggingagent-0.0.1-SNAPSHOT-jar-with-dependencies.jar

This was inspired by blog post:

http://today.java.net/article/2008/04/22/add-logging-class-load-time-java-instrumentation
Expand Up @@ -106,7 +106,8 @@ private byte[] doClass( final String name, final Class clazz, byte[] b ) {
}

/**
* modify code and add log statements
* modify code and add log statements before the original method is called
* and after the original method was called
*/
private void doMethod( final CtBehavior method ) throws NotFoundException, CannotCompileException {

Expand Down

0 comments on commit 2a54045

Please sign in to comment.