You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2014/07/19 23:01:00 UTC
Debugging JDBC
JDBC has this API:
java.sql.DriverManager.setLogWriter(PrintWriter)
How can we use that to log to Log4j 2?
Gary
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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
Re: Debugging JDBC
Posted by Gary Gregory <ga...@gmail.com>.
The other tricky part would be some setting to say "capture std out and/or
std err and send it to this log" because some trace API do not take a
stream or printer, for example
http://www-03.ibm.com/systems/power/software/i/toolbox/faq/#faq4
Gary
On Sun, Jul 20, 2014 at 1:14 AM, Matt Sicker <bo...@gmail.com> wrote:
> That is correct in regards to the toPrintWriter(). There's a bit of
> generated delegate code to create a usable call stack to get a readable
> calling class from.
>
>
> On 19 July 2014 23:21, Gary Gregory <ga...@gmail.com> wrote:
>
>> On Sun, Jul 20, 2014 at 12:18 AM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>>> So I would expect to be able to do this:
>>>
>>>
>>> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo").toPrintWriter());
>>>
>>> or, if Logger implments PrintWriter (a bit heavy IMO):
>>>
>>> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo"));
>>>
>>
>> Forget this last point since PrintWriter is a class, not an interface.
>>
>> Adding toPrintWriter() to the public API seems OK, but it might need to
>> be backed up by a bunch of code I suppose.
>>
>> Gary
>>
>>
>>> ?
>>>
>>> Gary
>>>
>>>
>>> On Sat, Jul 19, 2014 at 5:53 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>
>>>> Basically, you can get a PrintStream and a PrintWriter instance that
>>>> uses a Logger to write to instead of an actual OutputStream or Writer. It's
>>>> an additional jar, so it can be added on top of Log4j 2.
>>>>
>>>>
>>>> On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
>>>>
>>>>> Ah, right!
>>>>>
>>>>> Can't dig in now, but can that be added on top of Log4j 2 or does it
>>>>> have to be integrated _in_ log4j 2?
>>>>>
>>>>> Gary
>>>>>
>>>>>
>>>>> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>>
>>>>>> See branches/experimental/log4j-streams
>>>>>>
>>>>>> It's what Bruce and I worked on back when we were both newbies to
>>>>>> development here.
>>>>>>
>>>>>>
>>>>>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>
>>>>>>> JDBC has this API:
>>>>>>>
>>>>>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>>>>>
>>>>>>> How can we use that to log to Log4j 2?
>>>>>>>
>>>>>>> Gary
>>>>>>>
>>>>>>> --
>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>>> 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 <bo...@gmail.com>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>> 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 <bo...@gmail.com>
>>>>
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> 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
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> 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 <bo...@gmail.com>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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
Re: Debugging JDBC
Posted by Matt Sicker <bo...@gmail.com>.
Well, if you don't override the methods in PrintWriter, then the call stack
won't include the LogWriter class in the stack trace since it used a
super-class method. Then it becomes non-trivial to find the caller class in
the stack.
On 20 July 2014 00:54, Gary Gregory <ga...@gmail.com> wrote:
> On Sun, Jul 20, 2014 at 1:14 AM, Matt Sicker <bo...@gmail.com> wrote:
>
>> That is correct in regards to the toPrintWriter(). There's a bit of
>> generated delegate code to create a usable call stack to get a readable
>> calling class from.
>>
>
> Can you explain? Why do we need this? In my case, all I am doing to
> redirecting logging.
>
> Gary
>
>
>>
>> On 19 July 2014 23:21, Gary Gregory <ga...@gmail.com> wrote:
>>
>>> On Sun, Jul 20, 2014 at 12:18 AM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>>
>>>> So I would expect to be able to do this:
>>>>
>>>>
>>>> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo").toPrintWriter());
>>>>
>>>> or, if Logger implments PrintWriter (a bit heavy IMO):
>>>>
>>>> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo"));
>>>>
>>>
>>> Forget this last point since PrintWriter is a class, not an interface.
>>>
>>> Adding toPrintWriter() to the public API seems OK, but it might need to
>>> be backed up by a bunch of code I suppose.
>>>
>>> Gary
>>>
>>>
>>>> ?
>>>>
>>>> Gary
>>>>
>>>>
>>>> On Sat, Jul 19, 2014 at 5:53 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>
>>>>> Basically, you can get a PrintStream and a PrintWriter instance that
>>>>> uses a Logger to write to instead of an actual OutputStream or Writer. It's
>>>>> an additional jar, so it can be added on top of Log4j 2.
>>>>>
>>>>>
>>>>> On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
>>>>>
>>>>>> Ah, right!
>>>>>>
>>>>>> Can't dig in now, but can that be added on top of Log4j 2 or does it
>>>>>> have to be integrated _in_ log4j 2?
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>>
>>>>>> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> See branches/experimental/log4j-streams
>>>>>>>
>>>>>>> It's what Bruce and I worked on back when we were both newbies to
>>>>>>> development here.
>>>>>>>
>>>>>>>
>>>>>>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>>
>>>>>>>> JDBC has this API:
>>>>>>>>
>>>>>>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>>>>>>
>>>>>>>> How can we use that to log to Log4j 2?
>>>>>>>>
>>>>>>>> Gary
>>>>>>>>
>>>>>>>> --
>>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>>>> 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 <bo...@gmail.com>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>> 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 <bo...@gmail.com>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> 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
>>>>
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> 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 <bo...@gmail.com>
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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 <bo...@gmail.com>
Re: Debugging JDBC
Posted by Gary Gregory <ga...@gmail.com>.
On Sun, Jul 20, 2014 at 1:14 AM, Matt Sicker <bo...@gmail.com> wrote:
> That is correct in regards to the toPrintWriter(). There's a bit of
> generated delegate code to create a usable call stack to get a readable
> calling class from.
>
Can you explain? Why do we need this? In my case, all I am doing to
redirecting logging.
Gary
>
> On 19 July 2014 23:21, Gary Gregory <ga...@gmail.com> wrote:
>
>> On Sun, Jul 20, 2014 at 12:18 AM, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>>> So I would expect to be able to do this:
>>>
>>>
>>> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo").toPrintWriter());
>>>
>>> or, if Logger implments PrintWriter (a bit heavy IMO):
>>>
>>> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo"));
>>>
>>
>> Forget this last point since PrintWriter is a class, not an interface.
>>
>> Adding toPrintWriter() to the public API seems OK, but it might need to
>> be backed up by a bunch of code I suppose.
>>
>> Gary
>>
>>
>>> ?
>>>
>>> Gary
>>>
>>>
>>> On Sat, Jul 19, 2014 at 5:53 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>
>>>> Basically, you can get a PrintStream and a PrintWriter instance that
>>>> uses a Logger to write to instead of an actual OutputStream or Writer. It's
>>>> an additional jar, so it can be added on top of Log4j 2.
>>>>
>>>>
>>>> On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
>>>>
>>>>> Ah, right!
>>>>>
>>>>> Can't dig in now, but can that be added on top of Log4j 2 or does it
>>>>> have to be integrated _in_ log4j 2?
>>>>>
>>>>> Gary
>>>>>
>>>>>
>>>>> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>>
>>>>>> See branches/experimental/log4j-streams
>>>>>>
>>>>>> It's what Bruce and I worked on back when we were both newbies to
>>>>>> development here.
>>>>>>
>>>>>>
>>>>>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>>>>>
>>>>>>> JDBC has this API:
>>>>>>>
>>>>>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>>>>>
>>>>>>> How can we use that to log to Log4j 2?
>>>>>>>
>>>>>>> Gary
>>>>>>>
>>>>>>> --
>>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>>> 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 <bo...@gmail.com>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>> 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 <bo...@gmail.com>
>>>>
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> 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
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> 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 <bo...@gmail.com>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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
Re: Debugging JDBC
Posted by Matt Sicker <bo...@gmail.com>.
That is correct in regards to the toPrintWriter(). There's a bit of
generated delegate code to create a usable call stack to get a readable
calling class from.
On 19 July 2014 23:21, Gary Gregory <ga...@gmail.com> wrote:
> On Sun, Jul 20, 2014 at 12:18 AM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> So I would expect to be able to do this:
>>
>>
>> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo").toPrintWriter());
>>
>> or, if Logger implments PrintWriter (a bit heavy IMO):
>>
>> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo"));
>>
>
> Forget this last point since PrintWriter is a class, not an interface.
>
> Adding toPrintWriter() to the public API seems OK, but it might need to be
> backed up by a bunch of code I suppose.
>
> Gary
>
>
>> ?
>>
>> Gary
>>
>>
>> On Sat, Jul 19, 2014 at 5:53 PM, Matt Sicker <bo...@gmail.com> wrote:
>>
>>> Basically, you can get a PrintStream and a PrintWriter instance that
>>> uses a Logger to write to instead of an actual OutputStream or Writer. It's
>>> an additional jar, so it can be added on top of Log4j 2.
>>>
>>>
>>> On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
>>>
>>>> Ah, right!
>>>>
>>>> Can't dig in now, but can that be added on top of Log4j 2 or does it
>>>> have to be integrated _in_ log4j 2?
>>>>
>>>> Gary
>>>>
>>>>
>>>> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>
>>>>> See branches/experimental/log4j-streams
>>>>>
>>>>> It's what Bruce and I worked on back when we were both newbies to
>>>>> development here.
>>>>>
>>>>>
>>>>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>>>>
>>>>>> JDBC has this API:
>>>>>>
>>>>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>>>>
>>>>>> How can we use that to log to Log4j 2?
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>> --
>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>> 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 <bo...@gmail.com>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> 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 <bo...@gmail.com>
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> 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
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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 <bo...@gmail.com>
Re: Debugging JDBC
Posted by Gary Gregory <ga...@gmail.com>.
On Sun, Jul 20, 2014 at 12:18 AM, Gary Gregory <ga...@gmail.com>
wrote:
> So I would expect to be able to do this:
>
>
> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo").toPrintWriter());
>
> or, if Logger implments PrintWriter (a bit heavy IMO):
>
> java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo"));
>
Forget this last point since PrintWriter is a class, not an interface.
Adding toPrintWriter() to the public API seems OK, but it might need to be
backed up by a bunch of code I suppose.
Gary
> ?
>
> Gary
>
>
> On Sat, Jul 19, 2014 at 5:53 PM, Matt Sicker <bo...@gmail.com> wrote:
>
>> Basically, you can get a PrintStream and a PrintWriter instance that uses
>> a Logger to write to instead of an actual OutputStream or Writer. It's an
>> additional jar, so it can be added on top of Log4j 2.
>>
>>
>> On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
>>
>>> Ah, right!
>>>
>>> Can't dig in now, but can that be added on top of Log4j 2 or does it
>>> have to be integrated _in_ log4j 2?
>>>
>>> Gary
>>>
>>>
>>> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>
>>>> See branches/experimental/log4j-streams
>>>>
>>>> It's what Bruce and I worked on back when we were both newbies to
>>>> development here.
>>>>
>>>>
>>>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>>>
>>>>> JDBC has this API:
>>>>>
>>>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>>>
>>>>> How can we use that to log to Log4j 2?
>>>>>
>>>>> Gary
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>> 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 <bo...@gmail.com>
>>>>
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> 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 <bo...@gmail.com>
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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
Re: Debugging JDBC
Posted by Gary Gregory <ga...@gmail.com>.
So I would expect to be able to do this:
java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo").toPrintWriter());
or, if Logger implments PrintWriter (a bit heavy IMO):
java.sql.DriverManager.setLogWriter(LogManger.getLogger("com.foo"));
?
Gary
On Sat, Jul 19, 2014 at 5:53 PM, Matt Sicker <bo...@gmail.com> wrote:
> Basically, you can get a PrintStream and a PrintWriter instance that uses
> a Logger to write to instead of an actual OutputStream or Writer. It's an
> additional jar, so it can be added on top of Log4j 2.
>
>
> On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
>
>> Ah, right!
>>
>> Can't dig in now, but can that be added on top of Log4j 2 or does it have
>> to be integrated _in_ log4j 2?
>>
>> Gary
>>
>>
>> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
>>
>>> See branches/experimental/log4j-streams
>>>
>>> It's what Bruce and I worked on back when we were both newbies to
>>> development here.
>>>
>>>
>>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>>
>>>> JDBC has this API:
>>>>
>>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>>
>>>> How can we use that to log to Log4j 2?
>>>>
>>>> Gary
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> 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 <bo...@gmail.com>
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> 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 <bo...@gmail.com>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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
Re: Debugging JDBC
Posted by Matt Sicker <bo...@gmail.com>.
Well, it's more of an extension to log4j-api than to log4j-core.
On 19 July 2014 17:27, Gary Gregory <ga...@gmail.com> wrote:
> Which should be folded into core if it passes muster, right?
>
> Gary
>
>
> On Sat, Jul 19, 2014 at 6:19 PM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> Sounds like a great new feature for 2.1.
>>
>> Gary
>>
>>
>> On Sat, Jul 19, 2014 at 5:53 PM, Matt Sicker <bo...@gmail.com> wrote:
>>
>>> Basically, you can get a PrintStream and a PrintWriter instance that
>>> uses a Logger to write to instead of an actual OutputStream or Writer. It's
>>> an additional jar, so it can be added on top of Log4j 2.
>>>
>>>
>>> On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
>>>
>>>> Ah, right!
>>>>
>>>> Can't dig in now, but can that be added on top of Log4j 2 or does it
>>>> have to be integrated _in_ log4j 2?
>>>>
>>>> Gary
>>>>
>>>>
>>>> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>>
>>>>> See branches/experimental/log4j-streams
>>>>>
>>>>> It's what Bruce and I worked on back when we were both newbies to
>>>>> development here.
>>>>>
>>>>>
>>>>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>>>>
>>>>>> JDBC has this API:
>>>>>>
>>>>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>>>>
>>>>>> How can we use that to log to Log4j 2?
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>> --
>>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>>> 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 <bo...@gmail.com>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> 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 <bo...@gmail.com>
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> 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
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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 <bo...@gmail.com>
Re: Debugging JDBC
Posted by Gary Gregory <ga...@gmail.com>.
Which should be folded into core if it passes muster, right?
Gary
On Sat, Jul 19, 2014 at 6:19 PM, Gary Gregory <ga...@gmail.com>
wrote:
> Sounds like a great new feature for 2.1.
>
> Gary
>
>
> On Sat, Jul 19, 2014 at 5:53 PM, Matt Sicker <bo...@gmail.com> wrote:
>
>> Basically, you can get a PrintStream and a PrintWriter instance that uses
>> a Logger to write to instead of an actual OutputStream or Writer. It's an
>> additional jar, so it can be added on top of Log4j 2.
>>
>>
>> On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
>>
>>> Ah, right!
>>>
>>> Can't dig in now, but can that be added on top of Log4j 2 or does it
>>> have to be integrated _in_ log4j 2?
>>>
>>> Gary
>>>
>>>
>>> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
>>>
>>>> See branches/experimental/log4j-streams
>>>>
>>>> It's what Bruce and I worked on back when we were both newbies to
>>>> development here.
>>>>
>>>>
>>>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>>>
>>>>> JDBC has this API:
>>>>>
>>>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>>>
>>>>> How can we use that to log to Log4j 2?
>>>>>
>>>>> Gary
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>> 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 <bo...@gmail.com>
>>>>
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> 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 <bo...@gmail.com>
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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
Re: Debugging JDBC
Posted by Gary Gregory <ga...@gmail.com>.
Sounds like a great new feature for 2.1.
Gary
On Sat, Jul 19, 2014 at 5:53 PM, Matt Sicker <bo...@gmail.com> wrote:
> Basically, you can get a PrintStream and a PrintWriter instance that uses
> a Logger to write to instead of an actual OutputStream or Writer. It's an
> additional jar, so it can be added on top of Log4j 2.
>
>
> On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
>
>> Ah, right!
>>
>> Can't dig in now, but can that be added on top of Log4j 2 or does it have
>> to be integrated _in_ log4j 2?
>>
>> Gary
>>
>>
>> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
>>
>>> See branches/experimental/log4j-streams
>>>
>>> It's what Bruce and I worked on back when we were both newbies to
>>> development here.
>>>
>>>
>>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>>
>>>> JDBC has this API:
>>>>
>>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>>
>>>> How can we use that to log to Log4j 2?
>>>>
>>>> Gary
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> 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 <bo...@gmail.com>
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> 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 <bo...@gmail.com>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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
Re: Debugging JDBC
Posted by Matt Sicker <bo...@gmail.com>.
Basically, you can get a PrintStream and a PrintWriter instance that uses a
Logger to write to instead of an actual OutputStream or Writer. It's an
additional jar, so it can be added on top of Log4j 2.
On 19 July 2014 16:44, Gary Gregory <ga...@gmail.com> wrote:
> Ah, right!
>
> Can't dig in now, but can that be added on top of Log4j 2 or does it have
> to be integrated _in_ log4j 2?
>
> Gary
>
>
> On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
>
>> See branches/experimental/log4j-streams
>>
>> It's what Bruce and I worked on back when we were both newbies to
>> development here.
>>
>>
>> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>>
>>> JDBC has this API:
>>>
>>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>>
>>> How can we use that to log to Log4j 2?
>>>
>>> Gary
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> 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 <bo...@gmail.com>
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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 <bo...@gmail.com>
Re: Debugging JDBC
Posted by Gary Gregory <ga...@gmail.com>.
Ah, right!
Can't dig in now, but can that be added on top of Log4j 2 or does it have
to be integrated _in_ log4j 2?
Gary
On Sat, Jul 19, 2014 at 5:12 PM, Matt Sicker <bo...@gmail.com> wrote:
> See branches/experimental/log4j-streams
>
> It's what Bruce and I worked on back when we were both newbies to
> development here.
>
>
> On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
>
>> JDBC has this API:
>>
>> java.sql.DriverManager.setLogWriter(PrintWriter)
>>
>> How can we use that to log to Log4j 2?
>>
>> Gary
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> 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 <bo...@gmail.com>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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
Re: Debugging JDBC
Posted by Matt Sicker <bo...@gmail.com>.
See branches/experimental/log4j-streams
It's what Bruce and I worked on back when we were both newbies to
development here.
On 19 July 2014 16:01, Gary Gregory <ga...@gmail.com> wrote:
> JDBC has this API:
>
> java.sql.DriverManager.setLogWriter(PrintWriter)
>
> How can we use that to log to Log4j 2?
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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 <bo...@gmail.com>