Proper way to log in Idea plugins

I see there's an API to log errors:

    PluginManager.getLogger().error("test");


- the result is saved into the Idea "error log" and can be accessed by clicking on red blinking icon at the bottom.

now,  I also want to log warnings or some debug info and I'm trying to use:

    PluginManager.getLogger().warn("test");


This is not added to the errors list, so I guess I can't see these messages in Idea itself (?)
Does Idea have something similar to Eclipse "Error log" view, where plugins could log messages to in a standard way?
2
13 comments

I use the class: import com.intellij.openapi.diagnostic.Logger

Then:

private static final Logger log = Logger.getInstance();

I had never heard of PluginManager.getLogger until just now.

1
Avatar
Permanently deleted user

I just use log4j (actually, I use slf4j bridged to log4j, but same thing) to write trace and debug statements - it seems to write to the normal idea log just fine.

You can even add additional config to the the <idea home>/bin/log.xml file to get some custom log config going - writing all log statements from your plugin to a separate file, for example.

But it would be interesting to see some feedback from Jetbrains on the "right" way to deal with logging, since there seems to be a few different mechanisms.

0

Hello Shorn,

The right way is to use the IDEA logger class (com.intellij.openapi.diagnostic.Logger)

I use log4j (actually, I use slf4j bridged to log4j, but same thing)
to write trace and debug statments - it seems to write to the idea log
just fine.

You can even add additional config to the the <idea home>/bin/log.xml
file to get some custom log config going - writing all log statements
from your plugin to a separate file, for example.

But it would be interesting to see some feedback from Jetbrains on the
"right" way to deal with logging, since there seems to be a few
different mechanisms.


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


1
Avatar
Permanently deleted user

yole wrote:

The right way is to use the IDEA logger class (com.intellij.openapi.diagnostic.Logger)


Is there a way to view the logged info in the IDEA itself? Similar to Eclipse "Error Log"
eclipse_error_log.PNG

0

Hello Alexey,

The right way is to use the IDEA logger class
(com.intellij.openapi.diagnostic.Logger)



Is there a way to view the logged info in the IDEA itself? Similar to
Eclipse "Error Log"


The current version doesn't have any log view. It's possible that IDEA 11
will have something like that.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

But you can show idea.log of the instance which runs your plugin in the instance in which you develop your plugin if you start the plugin-running instance from your development instance. Just check the checkbox "Show idea.log" or how it is called in the the plugin run configuration. If you want to see it for an installed version of your plugin, you can use "tail -f" or any other log viewer to view idea.log.

0
Avatar
Permanently deleted user

the "IDEA LOG" View is great, that's what we need. Unfortunately, it will only be shown in the development IDEA and not in the one I start from it.

0
Avatar
Permanently deleted user

yole wrote:

The right way is to use the IDEA logger class
(com.intellij.openapi.diagnostic.Logger)

Is there a way to view the logged info in the IDEA itself? Similar to

Eclipse "Error Log"

The current version doesn't have any log view. It's possible that IDEA 11

will have something like that.

--


It would be nice to have that "IDEA LOG" available as a regular view. Is there an expected date for IDEA 11 release (at least "Early Access")?

0

Yes, as I said.
For the log of the IntelliJ you start the plugin with if you don't have a development IntelliJ or additionally to it as I said you would have to use some log viewer like
- "tail -f" from the command line
or
- http://plugins.intellij.net/plugin/?idea&id=1119
or
- http://plugins.intellij.net/plugin/?idea&id=46
But I don't know whether those plugins still work, they are quite old.

You can aloso trick the IntelliJ you are running your plugin with by making a run configuration that runs something that just sits there and waits and configure the idea.log as logfile for that run configuration.

0

Hello Alexey,

IDEA 11 will be out by the end of this year. We don't have any date for the
start of the EAP yet.

Note that you can build the latest Community Edition sources as often as
you want - all of its development is completely public.

yole wrote:
>
>> The right way is to use the IDEA logger class
>> (com.intellij.openapi.diagnostic.Logger)
>> Is there a way to view the logged info in the IDEA itself? Similar to
>>
>> Eclipse "Error Log"
>>
> The current version doesn't have any log view. It's possible that IDEA
> 11
>
> will have something like that.
>
> --
>

It would be nice to have that "IDEA LOG" available as a regular view.
Is there an expected date for IDEA 11 release (at least "Early
Access")?


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Avatar
Permanently deleted user

Hi!,

I use the IntelliJ logger:

import com.intellij.openapi.diagnostic.Logger;

but when I try:

LOG.debug("");

I don´t see the trace in the log file. I've tried with debug mode too but the result is the same Whit the others levels (info, warn or error) it works OK. Does anyone know why?

Thanks!

 

2
Avatar
Permanently deleted user
Notification notification =new Notification(... ...);//groupId is important for further settings
Nofifications.Bus.nofity(noitification);//Notifications, not Notification

This will print your message to Event Log ( at the right bottom of th IDE)

 

If you want to disable the balloon, you have to add :

notification.getBalloon().hide();
//i tried the param of hide(), but i cann't see any deferences between T and F.

AFTER  Nofifications.Bus.nofity(noitification);

Or you will get a NullPointerExcetion =)

 

The balloon and log could be also disabled/configed in Event Log if you group your notifications properly.

Hope this could be heplful to all of you.

0

If you just want to debug it locally, I found a way.

 

 

The path is /xxxxxxxxxxx/build/idea-sandbox/system/log/idea.log

Where xxx is the path of the current project.

 

Now you can use it this way

private static final Logger log = LoggerFactory.getLogger(PreviewAction.class);
private static final com.intellij.openapi.diagnostic.Logger LOGGER = com.intellij.openapi.diagnostic.Logger.getInstance(PreviewAction.class);

You can use either of the two. The log will be printed on console, and of course it will only be used for debugging in a sandbox environment.

 

I don't know if this is the right thing to do, but I am using it this way to debug my plug-in.

 

3

Please sign in to leave a comment.