Class LogTransformer

  • All Implemented Interfaces:
    java.lang.instrument.ClassFileTransformer

    public class LogTransformer
    extends java.lang.Object
    implements java.lang.instrument.ClassFileTransformer

    LogTransformer does the work of analyzing each class, and if appropriate add log statements to each method to allow logging entry/exit.

    This class is based on the article Add Logging at Class Load Time with Java Instrumentation.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  LogTransformer.Builder
      Builder provides a flexible way of configuring some of many options on the parent class instead of providing many constructors.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] transform​(java.lang.ClassLoader loader, java.lang.String className, java.lang.Class<?> clazz, java.security.ProtectionDomain domain, byte[] bytes)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.instrument.ClassFileTransformer

        transform
    • Method Detail

      • transform

        public byte[] transform​(java.lang.ClassLoader loader,
                                java.lang.String className,
                                java.lang.Class<?> clazz,
                                java.security.ProtectionDomain domain,
                                byte[] bytes)
        Specified by:
        transform in interface java.lang.instrument.ClassFileTransformer