问题
I am migrating to Logback from log4j. Log4j has the %l format specifier which will print out the fully qualified name of the calling method followed by the callers source the file name and line number between parentheses. Example: com.my.company.MyClass.doSomething(MyClass.java:54)
I want the same output using Logback. They don't have the %l format specified. They do have the %caller format specifier and when you provide the {0} option you will get the first level of the call stack. Example: Caller+0 at com.my.company.MyClass.doSomething(MyClass.java:54)
I don't want the prefix "Caller+0 at ". Is there a way to do this without having to create my own format specifier in which I would just remove that part of the string?
回答1:
try the following command in your compiling
javac -g
来源:https://stackoverflow.com/questions/19686432/can-you-alter-the-output-of-caller0-in-logback-to-mimic-log4j-l-specifier