On Thu, Oct 4, 2012 at 5:10 PM, Ralph Goers <[email protected]>wrote:
> One other thing. I would recommend changing your code below to
>
> public void error(final Throwable t, final String format, final Object...
> values) {
> this.logger.error(new StringFormattedMessage(format, values), t);
> }
>
Cool! OK, now I have:
public void error(final String format, final Throwable t, final
Object... values) {
this.logger.debug(new StringFormattedMessage(format, values), t);
}
But what about simply providing an API for this pattern? Like:
this.logger.formatError(format, t, values);
I'm not sure if "formatError" is the best name, but you get the idea.
This would let me get ride of a bunch of boiler plate code!
G
>
> This way String.format() isn't called unless the event is going to be
> logged.
>
> I'm not sure why your error method is logging at debug.
>
> Ralph
>
>
> On Oct 4, 2012, at 11:29 AM, Gary Gregory wrote:
>
> Hi All:
>
> In 2.0-Beta1, I have:
>
> public void error(final Throwable t, final String format, final
> Object... values) {
> this.logger.debug(String.format(format, values), t);
> }
>
> The formatted string is logged to the console but not the Exception.
>
> Am I missing something?
>
> My config looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration status="OFF">
> <appenders>
> <Console name="Console" target="SYSTEM_OUT">
> <PatternLayout pattern="%d{ ISO8601 } [%t] %-5level: %msg%n" />
> </Console>
> </appenders>
> <loggers>
> <logger name="com.foo" level="DEBUG" />
> <logger name="com.foo.bar" level="INFO" />
> <logger name="com.gargoylesoftware" level="INFO" />
> <root level="INFO">
> <appender-ref ref="Console" />
> </root>
> </loggers>
> </configuration>
>
> Merci!
> --
> E-Mail: [email protected] | [email protected]
> JUnit in Action, 2nd Ed: <http://goog_1249600977/>http://bit.ly/ECvg0
> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>
--
E-Mail: [email protected] | [email protected]
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory