Re: Logging stack traces conditionally

2016-10-28 Thread Mikael Ståldal
Can you do Marker SQL_WARN = ...; logger.warn(SQL_WARN, sqlWarning.getMessage(), sqlWarning); and then use different pattern layouts with message or throwable when that marker is used? On Thu, Oct 27, 2016 at 7:26 PM, Gary Gregory wrote: > On Thu, Oct 27, 2016 at 1:12 AM, Mikael Ståldal > wro

Re: Logging stack traces conditionally

2016-10-27 Thread Gary Gregory
On Thu, Oct 27, 2016 at 1:12 AM, Mikael Ståldal wrote: > Maybe logger.warn(SQL_WARN, "", sqlWarning); > Yeah, I am doing something like that but it does feel ugly: private static SQLWarning log(SQLWarning sqlWarning) { // (1) Log a plain warning but not the SQLWarning itself which i

Re: Logging stack traces conditionally

2016-10-27 Thread Mikael Ståldal
Maybe logger.warn(SQL_WARN, "", sqlWarning); On Thu, Oct 27, 2016 at 1:24 AM, Gary Gregory wrote: > On Wed, Oct 26, 2016 at 4:02 PM, Remko Popma > wrote: > >> I would split them up and use a marker: >> >> logger.warn(sqlWarning.getMessage()); >> logger.warn(SQL_WARN_EX, sqlWarning); >> > > I tr

Re: Logging stack traces conditionally

2016-10-26 Thread Matt Sicker
Wouldn't that introduce a new API compatibility issue like with the unrolled args issue? Like (Marker, null) would cause an ambiguous method. Then again, that might already be a problem if you try that. On 26 October 2016 at 18:24, Gary Gregory wrote: > On Wed, Oct 26, 2016 at 4:02 PM, Remko Pop

Re: Logging stack traces conditionally

2016-10-26 Thread Gary Gregory
On Wed, Oct 26, 2016 at 4:02 PM, Remko Popma wrote: > I would split them up and use a marker: > > logger.warn(sqlWarning.getMessage()); > logger.warn(SQL_WARN_EX, sqlWarning); > I tried that but the (Marker, Object) API logs the toString() of the exception, not the exception. It seems to me we

Re: Logging stack traces conditionally

2016-10-26 Thread Remko Popma
I would split them up and use a marker: logger.warn(sqlWarning.getMessage()); logger.warn(SQL_WARN_EX, sqlWarning); Then use a marker filter in configuration to exclude the stack traces with the marker. Sent from my iPhone > On 27 Oct 2016, at 2:41, Gary Gregory wrote: > > I have the follow

Logging stack traces conditionally

2016-10-26 Thread Gary Gregory
I have the following use cases that I am pondering on how to best handle: I log exceptions like a JDBC SQLWarning (a subclass of Exception): logger.warn(sqlWarning.getMessage(). sqlWarning); and I want to be able to tell users: "do this to hide this stack trace but you'll still see the message,