首先说明这是intellij idea带来的功能, 可以在console的日志输出里点击, 直接跳转到源码, 对我们开发调试程序时很是有用, 还可以方便的查看第三方的代码.
首先看一下intellij idea的说明:
[url]https://www.jetbrains.com/idea/help/setting-log-options.html[/url]
[quote]
If you are using third-party logging tools, you might want to make the message's output that mimics a standard linkage to the source code as for stacktrace line
(at <fully-qualified-class-name>.<method-name>(<file-name>:<line-number>)). For that, add specific Conversion Pattern to your log.xml configuration file.
For example, in a log4j Conversion Pattern this would be <param name="ConversionPattern" value="%-5p - [%-80m] - at %c.M(F:L)n"/>.
[/quote]
如果你用了spring-boot,且日志系统用的是logback, 则你可以这样写的logback.xml文件
注意那上面变量: [b]CONSOLE_LOG_PATTERN[/b] 这里的 [b]\\([/b] 是进行转换.
关于logback的那些参数说明, 请参见:
[url]http://logback.qos.ch/manual/layouts.html[/url]
[url]http://aub.iteye.com/blog/1103685[/url]
在 stackoverflow上也有个相应的问题:
[url]http://stackoverflow.com/questions/7930844/is-it-possible-to-have-clickable-class-names-in-console-output-in-intellij[/url]
附个打印出日志的截图:
[img]http://ww3.sinaimg.cn/mw690/69bff45bgw1eyedlgu9pbj20pv0cntbf.jpg[/img]
首先看一下intellij idea的说明:
[url]https://www.jetbrains.com/idea/help/setting-log-options.html[/url]
[quote]
If you are using third-party logging tools, you might want to make the message's output that mimics a standard linkage to the source code as for stacktrace line
(at <fully-qualified-class-name>.<method-name>(<file-name>:<line-number>)). For that, add specific Conversion Pattern to your log.xml configuration file.
For example, in a log4j Conversion Pattern this would be <param name="ConversionPattern" value="%-5p - [%-80m] - at %c.M(F:L)n"/>.
[/quote]
如果你用了spring-boot,且日志系统用的是logback, 则你可以这样写的logback.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %yellow(at %class.%method) \\(%file:%line\\) %n%clr(>>>>>>) %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
注意那上面变量: [b]CONSOLE_LOG_PATTERN[/b] 这里的 [b]\\([/b] 是进行转换.
关于logback的那些参数说明, 请参见:
[url]http://logback.qos.ch/manual/layouts.html[/url]
[url]http://aub.iteye.com/blog/1103685[/url]
在 stackoverflow上也有个相应的问题:
[url]http://stackoverflow.com/questions/7930844/is-it-possible-to-have-clickable-class-names-in-console-output-in-intellij[/url]
附个打印出日志的截图:
[img]http://ww3.sinaimg.cn/mw690/69bff45bgw1eyedlgu9pbj20pv0cntbf.jpg[/img]