Class LoggerPrintWriter

  • All Implemented Interfaces:
    Closeable, Flushable, Appendable, AutoCloseable

    public class LoggerPrintWriter
    extends PrintWriter
    Logs each line written to a pre-defined level. Can also be configured with a Marker. This class provides an interface that follows the PrintWriter methods in spirit, but doesn't require output to any external writer.

    Integration with JDBC logging can be as simple as:

         PrintWriter pw = IoBuilder.forLogger().setLevel(Level.DEBUG).buildPrintWriter();
         DriverManager.setLogWriter(pw);
         DataSource ds = ...
         ds.setLogWriter(pw);
     
    Since:
    2.1