Better support for log files

I'm using SLF4J on top of Logback and this produces log files with lines
like this:

2011-11-22 13:28:01,557 DEBUG e.s.e.e.EventModule

It's got the file name and line number - is there any reason why IDEA
can't turn that into a clickable link?

Also, stack traces?

I'm willing change the log file names to use a specific file suffix so
that IDEA knows that I want it to parse the file for file name/line
number pairs.

Thank you,



Hi Donald,

It's not possible to do that at the moment. Feel free to vote/tracke the progress of IDEA-73056.



There is a workaround you can use while waiting for this feature to be implmented. If your logging layout has the pattern  typivcally found in a stacktrace line, IDEA will create a link to it. So in your logging pattern, include the pattern

     at  <fully-qualified-class-name>.<method-name>(<file-name>:<line-number>)
for example:
     at com.example.SomeClass.main(

IDEA has a built in regex to parse for this pattern and create the necessary link. There use to be a tip of the day on this little useful gem, added by an old jira request I enetered four years ago. (see IDEA-41889). But I did not see the tip when I scrolled through the TOTDs just now.

In logback you can either do this "manually", or via the "caller" Conversion Word. For example:

  • <Pattern>%date %-5level at %logger.%method\(%file:%line\) - %message%n</Pattern>
  • <Pattern>%date %-5level - %message - %caller{1}</Pattern>

Two caveats of using the caller word:
1) you get the extraneous "Caller+0" text in your output
2) it places a new line at the end of it's output. So it is sometimes easier to use at the end of the line. Unless you like the look of the message on the next line. For example:

<Pattern>%date %-5level - %message - %caller{1}</Pattern>  produces:

2011-11-23 11:34:20,042 INFO  - Hello World - Caller+0     at com.example.SomeClass.main(
2011-11-23 11:34:20,044 INFO  - Goodbye World - Caller+0     at com.example.SomeClass.main(

<Pattern>%date %-5level - %caller{1} %message%n</Pattern> produces:

2011-11-23 11:27:34,048 INFO  - Caller+0     at com.example.SomeClass.main(
  Hello World
2011-11-23 11:27:34,050 INFO  - Caller+0     at com.example.SomeClass.main(
  Goodbye World

So in the end, it is usually just as easy to use the "manual" pattern so you can format it more to your liking.

For those in log4j, you can use the pattern:

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

Since you have to have the full qualified name, you do lose the logger name "truncation" feature of logback. So we use this pattern in our logback-test.xml configuration since 95% of the time that we want the advantage of linking in the classes is when running unit tests and such. For integration testing, we then have a different pattern defined based on the environment it is being run it. When run on a developer's local PC, we use a pattern with this "stacktrace" syntax in it. On our servers, it uses a more standard pattern. But, we also have a separate file that logs just error level messages, in addition to a file that logs all levels. This gives us place to easy monitor and look at for problems. In that error only log, we use the "stacktrace" syntax so we can copy and past the error message into IDEA's Analyze > Analyze Stacktrace... feature even if we do not have a stacktrace.

I'm willing change the log file names to use a specific file suffix...

Just in case you are not aware, you can configre a run/debug configuration to look at one or more log files regardless of the suffix on the "log" tab of the run/debug configuration.

I hope this helps. Again, it's a workaround while waiting for the feature to be implemented. Obviously the feature would be the preferred option.


Please sign in to leave a comment.