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)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5
    • Component/s: Appenders
    • Labels:
      None
    • Environment:

      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

              • Assignee:
                garydgregory Gary Gregory
                Reporter:
                garydgregory Gary Gregory
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: