-->

Can IntelliJ create hyperlinks to the source code

2020-08-16 03:36发布

问题:

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