Note that a call to catching(e) results in 

logMessage(FQCN, Level.ERROR, CATCHING_MARKER, catchingMsg(t), t);

Notice that the message is already filled in with the string “catching”, so 
specifying another message string wouldn’t make any sense. As Matt said, if you 
want more than just the single work “catching” as the message then do:

logger.error(AbstractLogger.CATCHING_MARKER, “Failed to import report. {}”, 
path, e);

Ralph

On Aug 24, 2014, at 9:40 AM, Matt Sicker <[email protected]> wrote:

> Use of catching/throwing is primarily for use in catching/throwing
> exceptions without any additional information that can't be obtained from
> the logger call. Basically, there are no calls like logger.error(e) for
> when you want to log just the exception, so instead you could use
> logger.catching(e). If you want to add more information, you should use the
> error/warn/etc. methods instead as you thought.
> 
> 
> On 24 August 2014 03:31, Aristedes Maniatis <[email protected]> wrote:
> 
>> Congratulations on the version 2 release. It looks great. A question
>> though about the recommended way to use the new 'catching syntax. We used
>> to do this:
>> 
>>    catch (Exception e ) {
>>      logger.warn("Failed to import report: " + path, e);
>> 
>> But now the new lifecycle syntax has some advantages. We can do this:
>> 
>>    catch (Exception e ) {
>>      logger.catching(e);
>> 
>> But it would be useful for me to log the path which ultimately caused the
>> exception. Except that I cannot do this:
>> 
>>    catch (Exception e ) {
>>      logger.catching("Failed to import report: {}", path, e);
>> 
>> 
>> What is the recommended approach here? Avoid the lifecycle style syntax?
>> Call the logger twice, once with my message and variable and once with the
>> exception?
>> 
>> 
>> Thanks
>> Ari
>> 
>> 
>> --
>> -------------------------->
>> Aristedes Maniatis
>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
>> 
> 
> 
> -- 
> Matt Sicker <[email protected]>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to