Can IntelliJ create hyperlinks to the source code from log4j output?

纵然是瞬间 提交于 2019-12-06 21:53:38

问题


In the IntelliJ console, stack traces automatically contain hyperlinks that bring you to the relevant source files. The links appear at the end of each line in the format (Log4jLoggerTest.java:25). I can configure log4j to output text in a similar format.

log4j.appender.Console.layout.ConversionPattern=%d{ABSOLUTE} (%F:%L) - %m%n

In eclipse, the console automatically turned text like this into links. In IntelliJ, the stack traces are links but my own output in the same form remains un-linked. Is there any way to get IntelliJ to do the same?


回答1:


Yes you can, try this pattern:

<param name="ConversionPattern" value="%-5p - [%-80m] - at %c.%M(%F:%L)%n"/>



回答2:


There is a plugin for IntelliJ IDEA to get clickable links in your console called Awesome Console.




回答3:


FYI, in loback and Intellij 13 this worked for me:

<pattern>%d{dd-MM-yyyy} %d{HH:mm:ss} %p %m - at %C.%M\(%F:%L\)%n</pattern>

Note: I needed the "at" and I also needed to escape the parentheses. Also capital "C" is the fully qualified classname in logback.

With this config I get output like:

10-06-2014 10:10:58 INFO Bean 'mbeanServer' of type [class com.sun.jmx.mbeanserver.JmxMBeanServer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) - at org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker.postProcessAfterInitialization(AbstractApplicationContext.java:1374)

And the final part in parentheses shows up as a link in Intellij.




回答4:


I don't think there is a way. But I think I submitted this as a feature request a long time ago. Maybe you should do the same. Jetbrains does listen to its customers. But it can take ages before they implement things like this.




回答5:


This works for me:

log4j.appender.console.layout.ConversionPattern=[%d{MM-dd HH:mm:ss}]%5p %l %m%n


来源:https://stackoverflow.com/questions/458820/can-intellij-create-hyperlinks-to-the-source-code-from-log4j-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!