From 43c1cf37e7fdbb2faced824de9b749610c4634a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Tue, 7 Sep 2021 16:21:29 +0200 Subject: [PATCH] new page: "IDE Infrastructure" - logging --- ijs.tree | 1 + topics/basics/ide_infrastructure.md | 74 +++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 topics/basics/ide_infrastructure.md diff --git a/ijs.tree b/ijs.tree index c082d3d50..6076c55cf 100644 --- a/ijs.tree +++ b/ijs.tree @@ -81,6 +81,7 @@ + diff --git a/topics/basics/ide_infrastructure.md b/topics/basics/ide_infrastructure.md new file mode 100644 index 000000000..577eddc57 --- /dev/null +++ b/topics/basics/ide_infrastructure.md @@ -0,0 +1,74 @@ +[//]: # (title: IDE Infrastructure) + + + + > This page is _Work in Progress_ - more information will be added over time. + > + {type="note"} + +### Logging + +The IntelliJ platform uses [`Logger`](upsource:///platform/util/src/com/intellij/openapi/diagnostic/Logger.java) abstraction class to shield from underlying logging implementation and configuration. + +Plugins should obtain a dedicated instance: + + + + +```java +import com.intellij.openapi.diagnostic.Logger; + +public class MyPluginFunctionality { + + private static final Logger LOG = Logger.getInstance(MyPluginFunctionality.class); + + public void someMethod() { + LOG.info("someMethod() was called"); + } + +} +``` + + + + + +```kotlin + +private val LOG = logger() + +class MyPluginFunctionality { + + fun someMethod() { + LOG.info("someMethod() was called") + } +} + +``` + +If logging is used only to report exceptions, use convenience method `thisLogger()`: + +```kotlin + + try { + // some code + } + catch (e: Throwable) { + thisLogger().error("some code failed", e) + } + +``` + + + + +By default, all messages with level `INFO` and higher are written to log output file idea.log. +To enable `DEBUG`/`TRACE` logging for specific categories, use Help | Diagnostic Tools | Debug Log Settings. + +When [internal mode](enabling_internal.md) is enabled, the currently running IDE log file can be opened using Help | Open Log in Editor or located in filesystem via Help | Show Log in Finder/Explorer action. + +To locate it for a specific installation, see this [Knowledge Base article](https://intellij-support.jetbrains.com/hc/en-us/articles/206544519). +See [Development Instance Sandbox Directory](ide_development_instance.md#the-development-instance-sandbox-directory) on how to find it for development instances. + +See [Testing FAQ](testing_faq.md) on how to enable `DEBUG`/`TRACE` level logging during tests, and obtain separate logs for failing tests. +