I still have a patch that has the work Bruce and I did with that. We have a
log4j-streams module for that. It's also in a branch somewhere, but I've
had to convert it into a patch due to divergence from the trunk. I'll make
a new git branch or something later tonight.


On 29 August 2014 12:36, Gary Gregory <[email protected]> wrote:

> Hi All,
>
> In am now developing some fancy JDBC proprietary do-hicky at work.
>
> In JDBC, you log to a java.io.PrintWriter like this:
>
> // for all drivers
> DriverManager.setLogWriter(printWriter);
>
> // for a specific driver (if that driver support it).
> dataSource.setLogWriter(printWriter);
>
> I want logging to go to Log4j 2. Granted, I've got no control with levels
> but at least I could give it a (single) level (see below) and, as usual, if
> I want the target to be the console or a file and do rollovers and such.
>
> I could see wrapping a PW and then giving that to JDBC and Log4j somehow:
>
> log4jPw = new Log4jPrintWriter(logger, Level.DEBUG);
>
> ... someLog4jObject.addEventSource(log4jPw);
>
> DriverManager.setLogWriter(log4jPw);
> // or
> dataSource.setLogWriter(log4jPw);
>
> The PW would buffer until it gets a println() or the buffer reaches some
> size limit, then turns its buffer into log event.
>
> Also, JDBC 4.1 in Java 7 has some integration with JUL with
> javax.sql.CommonDataSource.getParentLogger() but each driver has to support
> that.
>
> My requirements look like a perfect match with log4j2-547 and it looks
> like Bruce put a lot of work in there.
>
> So I am going to experiment to bring that code base in.
>
> Thoughts?
>
> Gary
>
> --
> E-Mail: [email protected] | [email protected]
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <[email protected]>

Reply via email to