How do I configure Logback to print out the class name

后端 未结 6 1048
渐次进展
渐次进展 2020-12-10 11:08

I\'m using Play 2.1. I\'m using the default logger play.api.Logger. I\'m confused about how it works.

In my scala code, a line in class \"com.myapp.tickets\" in th

6条回答
  •  再見小時候
    2020-12-10 11:55

    %class{0} will only output the class name, so instead of:

    com.something.MyClass
    

    You'll get:

    MyClass
    

    This is how my pattern for logback normally looks:

    %d{HH:mm:ss} [%thread] %-5p %class{0} - %m%n
    

    You can also add the method and the line if you are interested by doing:

    %d{HH:mm:ss} [%thread] %-5p %class{0}.%method:%L - %m%n
    

提交回复
热议问题