Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please don't override log4j configuration in IDE #27

Open
ForNeVeR opened this issue Jan 25, 2021 · 1 comment
Open

Please don't override log4j configuration in IDE #27

ForNeVeR opened this issue Jan 25, 2021 · 1 comment

Comments

@ForNeVeR
Copy link

ForNeVeR commented Jan 25, 2021

While investigating #22, we've found the root cause of the issue: it's the log.xml configuration file which is loaded by the LuaLoggerManager component:

final VirtualFile logXml = LuaFileUtil.getPluginVirtualDirectoryChild("log.xml");
File logXmlFile = new File(logXml.getPath());
String text = FileUtil.loadFile(logXmlFile);
text = StringUtil.replace(text, SYSTEM_MACRO, StringUtil.replace(PathManager.getSystemPath(), "\\", "\\\\"));
text = StringUtil.replace(text, APPLICATION_MACRO, StringUtil.replace(PathManager.getHomePath(), "\\", "\\\\"));
text = StringUtil.replace(text, LOG_DIR_MACRO, StringUtil.replace(PathManager.getLogPath(), "\\", "\\\\"));
new DOMConfigurator().doConfigure(new StringReader(text), LogManager.getLoggerRepository());

(note that, while this component is disabled in the source code of the plugin, it is, nevertheless, enabled in the plugin builds uploaded to the Marketplace, which I've already reported as #26)

This log.xml configures the following appender:

IDLua/include/log.xml

Lines 5 to 13 in ffc0589

<appender name="CONSOLE-WARN" class="org.apache.log4j.ConsoleAppender">
<param name="target" value="System.err"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%7r] %6p - %30.30c - %m \n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="WARN"/>
</filter>
</appender>

This appender just passes logs with WARN level to the process' stderr.

At the same time, Rider (for reasons beyond the scope of current investigation) has a special mechanism that does a reverse thing: takes its stderr and passes back to logger.

So, any log with the WARN level will get passed to the logger, which will try to write it into stderr, which will get mirrored back to the logger, etc. etc., which will either cause a stack overflow or out of memory error (we've encountered both during the investigation).

While this particular issue will likely be fixed in Rider 2021.1, it isn't recommended to change the IDE log settings from the plugin. Instead of that, please use the IDE logging system as-is and use the IDE debug log settings (available in Help → Diagnostic Tools → Debug Log Settings… main menu item) if you want to enable / disable logging on the go.

@floating-cat
Copy link

I just noticed that the IDEA would now log all DEBUG level logs after enabling the Lua plugin.
It seems this log problem is also caused by this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants