Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1178

Support use-case for JDBC's CommonDataSource.setLogWriter(PrintWriter) and java.sql.DriverManager.setLogWriter(PrintWriter)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.5
    • Appenders
    • None

    Description

      I am writing a JDBC driver. The JDBC Spec has a a method DataSource.setLogWriter(PrintStream) API drivers should implement.

      Users can drop our driver into any tool that talks JDBC or write their own apps. In am concerned about the 'drop the driver anywhere' scenario, like in an Eclipse based tool; that may or may not use Eclipse DTP. Or anything else.

      The setLogWriter() API can be called at any time, after Log4j has initialized itself for example.

      I do all my driver logging through Log4j. If a tool calls setLogWriter(), I'd like the given PrintStream to become an Appender such that Log4j output appears there.

      The only way I see to do that is through pseudo-code like "getLoggerContext().getConfiguration().addAppender(PrintStreamAppender.createPrintStreamAppender(aPrintStream))"

      I think that would need to be followed by a full reconfigure.

      Can we use our new builder API to add to the current config and reconfigure?

      This also applies to java.sql.DriverManager.setLogWriter(PrintWriter) and java.sql.DriverManager.setLogStream(PrintStream)

      Attachments

        Issue Links

          Activity

            People

              ggregory Gary D. Gregory
              ggregory Gary D. Gregory
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: