Logging from plugin

Im using Log4j in my plugin.  Ive edited the $IDEA_HOME/bin/log.xml to include my rolling file appender,
logger and appender-refs, just as I do for all my projects.  However, when I restart Idea, I dont get any log output in my log file.  I see that the log file is created, but there's no content.
Ive got my logger set to log DEBUG, and additivity=false (since I want my plugin log to be separate), and Im logging at info and warning level.

Any reason Im not seeing any log output from my plugin (I see Ideas output in idea.log)?

0

I figured this out after stepping through the logging init.

Although Idea looks like its using plain old log4j, complete with a log4j config, it's using a wrapper around it.
So although you might have the $IDEA_HOME/bin/log.xml configured correctly, if you use a log4j Logger directly in your plugin code, it will be using a completely different set of log configs.

The trick is to use the Logger provided in com.intellij.openapi.diagnostic.Logger and then obtain a Logger using Logger.getInstance( String loggerName ) and not to have a log4j.jar library in your plugin - just call up to the IntelliJ wrapper.

If there's a better way to log from a plugin, please append to this thread.

0

请先登录再写评论。