繁体   English   中英

Jboss EAP 6.3线程与log4j ConsoleAppender陷入僵局

[英]Jboss EAP 6.3 threads get deadlock with log4j ConsoleAppender

从Jboss 5升级到Jboss EAP 6.3.0后,我们发现应用程序在运行一段时间后会失败。 看一下,它开始增加接受HTTP请求但无法为它们提供服务的线程数量。 之后,ThreadDump向我们显示了log4j的死锁:

Found one Java-level deadlock:
=============================
"http-/0.0.0.0:39002-109":
  waiting to lock monitor 0x0000000013d2a218 (object 0x00000000c1cc7aa8, a org.apache.log4j.ConsoleAppender),
  which is held by "http-/0.0.0.0:39002-12"
"http-/0.0.0.0:39002-12":
  waiting to lock monitor 0x000000001456c128 (object 0x00000000c1cca400, a java.io.PrintStream),
  which is held by "http-/0.0.0.0:39002-74"
"http-/0.0.0.0:39002-74":
  waiting to lock monitor 0x0000000013d2a218 (object 0x00000000c1cc7aa8, a org.apache.log4j.ConsoleAppender),
  which is held by "http-/0.0.0.0:39002-12"

与开发团队交谈,在应用程序中删除了对log4j的所有引用,仅将配置保留在standalone.xml上,以便将某些类记录到某些特定文件中,这是与记录有关的相关配置:

    <periodic-rotating-file-handler name="FILE" autoflush="true">
        <formatter>
            <named-formatter name="PATTERN"/>
        </formatter>
        <file relative-to="jboss.server.log.dir" path="server.log"/>
        <suffix value=".yyyy-MM-dd"/>
        <append value="true"/>
    </periodic-rotating-file-handler>
    <size-rotating-file-handler name="DocumentalServices">
        <file relative-to="jboss.server.log.dir" path="DocumentalServices.log"/>
        <rotate-size value="10m"/>
        <max-backup-index value="5"/>
    </size-rotating-file-handler>
    <size-rotating-file-handler name="DataServices">
        <file relative-to="jboss.server.log.dir" path="DataServices.log"/>
        <rotate-size value="10m"/>
        <max-backup-index value="5"/>
    </size-rotating-file-handler>
    <size-rotating-file-handler name="Audit">
        <file relative-to="jboss.server.log.dir" path="audit.log"/>
        <rotate-size value="10m"/>
        <max-backup-index value="5"/>
    </size-rotating-file-handler>
    <logger category="com.documentation.framework.ws" use-parent-handlers="false">
        <level name="DEBUG"/>
        <handlers>
            <handler name="DocumentalServices"/>
        </handlers>
    </logger>
    <logger category="com.documentation.framework.data" use-parent-handlers="false">
        <level name="DEBUG"/>
        <handlers>
            <handler name="DataServices"/>
        </handlers>
    </logger>
    <logger category="com.documentation.framework.core.audit" use-parent-handlers="false">
        <level name="DEBUG"/>
        <handlers>
            <handler name="Audit"/>
        </handlers>
    </logger>
    <root-logger>
        <level name="INFO"/>
        <handlers>
            <handler name="FILE"/>
        </handlers>
    </root-logger>

考虑到我们不是在root-logger内登录控制台,而只是在FILE(server.log)上登录,在ConsoleAppender上的死锁似乎有些奇怪。

必须添加一些log4j ConsoleAppender。 据我所知,这可能是Spring,他们在做一些伐木技巧。 在启动过程中,您可以尝试传递-Dorg.jboss.as.logging.per-deployment=false ,如果找到了log4j.xml或log4j.properties文件,这将禁止JBoss EAP尝试配置log4j。

另一个选择可能是在日志记录子系统中将add-logging-api-dependenciesfalse 您需要在部署中包括一个log4j库,因为它似乎取决于它。 这是CLI更改默认设置的样子。

/subsystem=logging:write-attribute(name=add-logging-api-dependencies,value=false)

请注意,禁用此功能会影响所有部署。

也就是说,问题是log4j ConsoleAppender的工作方式。 它总是直接记录到System.xxx JBoss EAP将stdoutstderr包装在记录器中,这导致了死锁。

有个修复程序应该在6.4版本中最终出现。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM