简体   繁体   English

Log4j2 SMTPAppender 不发送电子邮件

[英]Log4j2 SMTPAppender not sending email

My question is similar to these two:我的问题类似于这两个:

but I am not able to send SMTPs at all, and I do not want to put the <appender-ref ref="SMTPAppender" /> inside the root logger.但我根本无法发送 SMTP,而且我不想将<appender-ref ref="SMTPAppender" />放在根记录器中。 If i did, i would receive emails from every logger.如果我这样做了,我会收到来自每个记录器的电子邮件。 So the SMTPAppender is able to send SMTPs but I just want the notificationLogger to be the only logger sending emails.所以 SMTPAppender 能够发送 SMTP,但我只希望notificationLogger成为唯一发送电子邮件的记录器。

Here is my log4j2.xml file:这是我的 log4j2.xml 文件:

    <loggers>
        <logger name="notificationLogger" level="fatal" additivity="false">
            <appender-ref ref="SMTPAppender" /> 
            <appender-ref ref="stdout" />
        </logger>
        <logger name="com.prod" level="INFO">
            <appender-ref ref="RollingFile"/>
        </logger>
        <root level="INFO">
            <appender-ref ref="stdout"/>
        </root>
    </loggers>

What do i do in order to have the notificationLogger be the only logger sending SMTPs?我该怎么做才能让notificationLogger成为唯一发送 SMTP 的记录器?

Not an expert on this but...不是这方面的专家,但...

Isn't this a known bug?这不是一个已知的错误吗?

https://issues.apache.org/jira/browse/LOG4J2-310 https://issues.apache.org/jira/browse/LOG4J2-310

I had to update my maven dependencies to fix a known bug.我不得不更新我的 Maven 依赖项来修复一个已知的错误。

  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.0-beta9</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.0-beta9</version>
  </dependency>

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

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