magenta placenta
magenta placenta

Reputation: 1535

How do I see my server logs in IntelliJ IDEA Community Edition

I just got a new PC at work and I'm giving IntelliJ IDEA Community Edition a go because I'm not the biggest fan of Eclipse. I figure now is the perfect time to try another IDE.

I can't seem to figure out how to see my app server logs/exceptions in the IDE, though. The closest thing I've found is to enable two checkboxes (they were unchecked on a fresh install) via:

Run --> Edit Configurations --> Application --> Logs (tab)

X Show console when standard out changes

X Show console when standard error changes

I'm just not finding any window/pane/tab with logs I can turn on. I've stopped/restarted my server, quit/relaunched IntelliJ.

Are server logs not available o view in the Community Edition IDE?

Upvotes: 16

Views: 46200

Answers (3)

Rajashree Gr
Rajashree Gr

Reputation: 589

In intellij, go to Run > Edit configuration > [your tomcat instance] > tab Startup/Connection and click on the ‘Run’ setup. In the lower part of the dialog, check ‘Pass environment variables’ and add variable CATALINA_BASE pointing to your tomcat instance, in my case /Users/ramanna/apps/apache-tomcat-9.0.13.

Now select tab ‘Logs’ in the same dialog, add (using the green + on the right) the log file, where the logs are supposed to be (in my case /Users/ramanna/apps/apache-tomcat-9.0.13/logs/catalina.out)

Upvotes: 2

NIKHIL CHAURASIA
NIKHIL CHAURASIA

Reputation: 547

I don't know about "Community Edition", but mine is IntelliJ Idea 15.0.3 & I found this one working for me. aplogies if yours is different version.

Go to View > Tool Windows > Application Servers

Now you can see server widget on the lower left side of IntelliJIdea Now, whenever you will debug / run the project, your server's log will be displayed here in the tab right of servers. (As, Tomcat Localhost Log & Tomcat Catalina Log in my case) shown in the attached screenshot below. Please refer.

enter image description here

Upvotes: 2

Javaru
Javaru

Reputation: 31936

Most likely your server is writing to its own log files, and not to System.out or System.err. Where those are located will depend on your server. For example, Tomcat's logs will be in <tomcatInstallDir>/logs. The Ultimate edition, which has server run configurations, will automatically open those logs (for most server types). For the Communality Edition, you will need to find where those logs are and then configure IDEA to automatically show them when you run your application.

On the "logs" tab, add a "Log file to be shown in console" by clicking the add button enter image description hereon the right. Then define the log file location. You can use an Ant File Pattern to match the file. This is useful for log files with a date in them. If you leave the "Show All files coverable by pattern" unchecked, IntelliJ IDEA will only show the latest/newest one. Finally, after creating the log definition, you can check the "Skip Content" button if you only want new messages shown when you launch the application/server (that is only messages from the current run. Messages from previous runs are not shown.)

Here's an example:

enter image description here

The above example was done in the Ultimate Edition. But the Community Edition has the same logs tab.

UPDATE

In response to your (first) comment, the log will appear as a tab on the run (or debug) tool window when you run your application. The tab name will match the alias you entered in the above configuration. For example:

enter image description here

Note: The text highlighting and output folding is done via the Grep Console Plug-in

I will mention a few "gotchas" with this feature:

  1. It takes a few seconds for the log tabs to display. As a result, for a very quick running app (like a simple test), the tab may not end up showing
  2. When using the "Skip Content" feature, sometimes the log tab is empty the first time you run the application. This seems especially problematic for log files that are not using a file pattern. Unfortunately I have not been able to nail down a consistent use case in order to open up a bug report. Turning off "skip Content" resolves the issue.

I hope that helps.

Upvotes: 15

Related Questions