20

How can I log something for debugging purpose from within a IntelliJ plugin? (I'm not using Community Edition)

Bruno Caceiro
  • 6,179
  • 1
  • 19
  • 37
Alireza Mirian
  • 3,995
  • 2
  • 23
  • 45
  • It's unclear what you're asking. Why do you need to log from a plugin? Can't you use dedicated logging library from inside your codebase? Or do you want to write your own plugin? – Filip Malczak Aug 30 '15 at 07:53
  • 1
    I'm writing my own plugin. I just want to log something somewhere in my code and see the logged value. – Alireza Mirian Aug 30 '15 at 08:25

2 Answers2

17

com.intellij.openapi.diagnostic.Logger is the officially recommended logger to use for IntelliJ plugin development. See this for more details: https://devnet.jetbrains.com/message/5306410#5306410

The thread is old so some of the other information might be outdated, that class still exists and should be used for logging.

Zarwan
  • 4,799
  • 3
  • 26
  • 46
  • http://stackoverflow.com/questions/34855314/idea-intellij-plugin-not-working-in-android-studio-1-5-1 – Adi Jan 18 '16 at 13:14
  • 2
    I use this to instantiate it: `private static final Logger LOGGER = Logger.getInstance(MyClass.class);` – Maria Ines Parnisari Dec 05 '17 at 05:23
  • Just to add this for others: the log lines would appear in the idea.log of the sandbox in which your plugin is running. You can find log files under `/system/log/` directory. Sandbox directory is configured by gradle-intellij-plugin and points to `/build/idea-sandbox` by default. – gurpal2000 Apr 09 '21 at 20:26
0

I think that this will be helpful. It is a wrapper that provides logging based on IDEA internals or java.util.logging (if internals aren't available).

Filip Malczak
  • 2,926
  • 22
  • 41