com.intellij.openapi.diagnostic.Logger debug() statements are not visible in the console

Answered

I'm sure it is something very obvious that I'm missing but I can't figure out how to make my plugin's logger.debug() statements visible in the IntelliJ console. My plugin project is Gradle-based and I run the plugin from within IntelliJ by calling the runIdea Gradle task. If I replace logger.debug() with System.out.println(), I can see the output in the console, but obviously I don't want to leave this kind of code there :)

 

2
7 comments
Official comment

Hi Eugene,

 

Making logger.debug() visible in standard output is not better than keeping System.out.println() in your code, you don't need it.

Logger.debug() is logging messages to idea.log of started IDE instance. You can find log files under `<sandbox_directory>/system/log/` directory. Sandbox directory is configured by gradle-intellij-plugin and points to `<project_dir>/build/idea-sandbox` by default.

 

The most convenient way to see the logs of running IDE is to add a tab to Run tool window with content of idea.log file:

To do this just add log file in Gradle run configuration settings:

By default IDE logging severity is INFO. To override this, use `Help | Debug Log Settings` action of IDE that you run via `runIdea` task

1

Thank you very much, sir! This is exactly what I was looking for! The only problem now is I can't figure out the log category name to add to the Debug Log Settings list. Is it a class name, package name or anything else? I instantiate the logger as follows:

final static Logger logger = Logger.getInstance(MySillyAction.class);

and MySillyAction has package com.foo.bar. So what should I add to the Debug Log Settings:

MySillyAction
com.foo.bar.MySillyAction
com.foo.bar

or anything else?

I tried all the combinations so far but I don't see my debug output. 

 

 

0

According to the sources, Logger adds '#' prefix when you creating a logger for class (https://github.com/JetBrains/intellij-community/blob/master/platform/util/src/com/intellij/openapi/diagnostic/Logger.java#L79). So please try `#com.foo.bar.MySillyAction`, hope this works

1

And it works! 

Damn, I wish all this was properly documented, but I guess I'm asking too much, am I? :)

Thanks very much again!

 

 

1

I am glad to have found out this question and the response from Alex.

But I think I am still not clear on one things.

I have a util class which has a method with Debug statement.

Everytime an action runs, I want to make sure that debug statement is logged somewhere:

So I added this to the class

private static final Logger LOG = Logger.getInstance("#org.foo.MyUtil");

and then

LOG.debug("MyUtil: Time taken to load gradle.properties file: " + elaspedTime + "ms");

and then in the running idea instance -> Help -> Debug log settings, I added

#org.foo.MyUtil

 

But when I run that action from the running IDE, I do not see the log in the  idea.log file

When I compile the project, the above debug statement appears in build/build.log

 

Though I am getting the debug statement, I would really like that this statement comes in the idea.log on executing that action and not on the compilation of the project and in build.log

 

Any idea what am I missing here.

0

Hi Vicky,

Sorry for a late response.

> Any idea what am I missing here.

Not really, do you see any other debug log statements in idea.log while running IDE from IDE? Please verify that logging severity is set to `all` (see the first screenshot in the thread, the combobox is nearby the search field).

0

Please sign in to leave a comment.