[
https://issues.apache.org/jira/browse/LOG4J2-488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13865715#comment-13865715
]
Olivier Lemasle commented on LOG4J2-488:
----------------------------------------
Yes, it's by design. It's stated in the documentation for SMTPAppender:
bq. The default behavior is to trigger sending an email whenever an ERROR or
higher severity event is logged.
For SMTPAppender, the filter defaults to ThresholdFilter, level of ERROR.
> SMTPAppender Does Not Log Below Level "Error"
> ---------------------------------------------
>
> Key: LOG4J2-488
> URL: https://issues.apache.org/jira/browse/LOG4J2-488
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 2.0-beta9
> Environment: Tomcat, Servlet 3.0
> Reporter: Michael Mast
> Priority: Minor
> Attachments: SMTPAppenderTest.java, log4j2-smtp.xml
>
>
> SMTPAppender attempts to connect to SMTP server only when logging at level
> Error or Fatal, regardless of the level defined in Log4J2.xml.
> This bug sounds similar to LOG4J2-310, "SMTPAppender does not send mails with
> error or fatal level without prior info event," but it is different.
> Steps to reproduce:
> This code:
> {code}
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> class LogTest {
> private static Logger logger = LogManager.getLogger("LogTest");
> public void testlogger() {
> logger.info("test info"); // does not log
> logger.error("test error"); // logs!
> }
> public static void main(String[] args) {
> LogTest app = new LogTest();
> app.testlogger();
> }
> }
> {code}
> With this configuration file:
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration status="warn">
> <!-- Mail server configuration. You don't need to change these to see
> the
> problem with SMTPAppender. Because smtpDebug is set to "true"
> you'll see
> that the appender makes no attempt whatsoever to connect to an
> SMTP server
> while logging at any level other than fatal or error, thus
> demonstrating
> the bug. -->
> <properties>
> <property name="receipients">[email protected]</property>
> <property name="from">[email protected]</property>
> <property name="smtpHost">smtp.example.com</property>
> <property name="smtpPort">25</property>
> <property name="smtpProtocol">smtp</property>
> <property name="smtpUser">me</property>
> <property name="smtpPassword">secret</property>
> </properties>
> <appenders>
> <!-- appender to write all info events to stdout -->
> <Console name="Console" target="SYSTEM_OUT">
> <ThresholdFilter level="info" onMatch="NEUTRAL"
> onMismatch="DENY" />
> </Console>
> <!-- appender to send mails (default: error and fatal events)
> -->
> <SMTP name="Mailer" ignoreExceptions="false" subject="Error log"
> to="${receipients}" from="${from}"
> smtpHost="${smtpHost}" smtpPort="${smtpPort}"
> smtpProtocol="${smtpProtocol}"
> smtpUsername="${smtpUser}"
> smtpPassword="${smtpPassword}" smtpDebug="true"
> bufferSize="2">
> </SMTP>
> <!-- appender to send mails asynchronously -->
> <Async name="AsyncMailer">
> <appender-ref ref="Mailer" />
> </Async>
> </appenders>
> <loggers>
> <!-- logger to send mail on (at least) info level events -->
> <logger name="LogTest" level="info" additivity="true">
> <appender-ref ref="AsyncMailer" />
> </logger>
> <!-- root logger to see what happens (info level and "above")
> -->
> <root level="info">
> <appender-ref ref="Console" />
> </root>
> </loggers>
> </configuration>
> {code}
> Demonstrates the problem.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]