Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is wrong with this Logback pattern?

I'm using this pattern:

   <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - (%file:%line) - %msg%n</pattern>

Yet the output looks like:

09:42:25.811 WARN a.a.an.dao.api.ANApi - (ANApi.java:153

The pattern appears to be truncated after the %line (it also happens if I use %L) - what am I doing wrong?

I need this specific pattern so that Eclipse's console will recognize it.

like image 205
sanity Avatar asked Apr 13 '12 14:04

sanity


1 Answers

( and ) have a special meaning, as explained on logback website:

In PatternLayout, parenthesis can be used to group conversion patterns. It follows that the '(' and ')' carry special meaning and need to be escaped if intended to be used as literals. The special nature of parenthesis is further explained below.

In your case you need to escape them with a backslash:

<pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - \(%file:%line\) - %msg%n</pattern>
like image 130
assylias Avatar answered Sep 18 '22 11:09

assylias