# Send ERROR logs by email - SMTP appender

**URL:** <https://discuss.elastic.co/t/send-error-logs-by-email-smtp-appender/29387>\
**Category:** Elasticsearch\
**Created:** [September 16, 2015, 11:51am UTC](https://discuss.elastic.co/t/send-error-logs-by-email-smtp-appender/29387 "2015-09-16T11:51:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emanuel\_Buzek](https://avatars.discourse-cdn.com/v4/letter/e/df705f/32.png) [@Emanuel\_Buzek](https://discuss.elastic.co/u/Emanuel_Buzek)\
**Post date:** [September 16, 2015, 11:51am UTC](https://discuss.elastic.co/t/send-error-logs-by-email-smtp-appender/29387/1 "2015-09-16T11:51:56Z")

</div>

Hi everyone,

it looks like multiple ES users have asked this question, but I cannot find any working solution online. I am trying to configure a SMTP log4j appender in my logging.yml to send ERROR logs by email.

My logging.yml (not working, no email sent...):

es.logger.level: INFO  
rootLogger: ${es.logger.level}, console, file, mail  
logger:

appender:  
console:  
type: console  
layout:  
type: consolePattern  
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"

file:  
type: dailyRollingFile  
file: ${path.logs}/${cluster.name}.log  
datePattern: "'.'yyyy-MM-dd"  
layout:  
type: pattern  
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"

mail:  
type: smtp  
layout:  
type: pattern  
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"  
from: [bugs@xyz.com](mailto:bugs@xyz.com)  
host: 192.168.42.7  
to: [bugs@xyz.com](mailto:bugs@xyz.com)  
subject: "ES LOG"

Thanks in advance for suggestions / working solutions.

* * *

related threads:

> [@Log4j: Configuring SMTPAppender](https://discuss.elastic.co/t/log4j-configuring-smtpappender/22045):
>
> Hi all, I'd like to configure a smtpappender in logging.yml so that an email is sent whenever a message is logged. Unfortunately, the yml configuration isn't very well documented on log4j homepage and I wasn't able to find any working example in the www. I also tried to put a separate logging.properties in $ES\_HOME$/config, but didn't get it working. My last try (not working - no email is being sent): es.logger.level: INFO rootLogger: ${es.logger.level}, console, file, email logger: .…

> [@Logging.yml configuration for emailing errors](https://discuss.elastic.co/t/logging-yml-configuration-for-emailing-errors/10751):
>
> Hi, I would like to receive an email when my cluster logs an error. How do I configure the logging.yml? Bye, René -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com). For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 16, 2015, 1:16pm UTC](https://discuss.elastic.co/t/send-error-logs-by-email-smtp-appender/29387/2 "2015-09-16T13:16:32Z")

</div>

It looks like `smtp` is supposed to setup `org.apache.log4j.net.SMTPAppender`:

> <https://github.com/elastic/elasticsearch/blob/ea4c27a089697e4cf167d06836b0324c8da8964b/core/src/main/java/org/elasticsearch/common/logging/log4j/LogConfigurator.java#L68>

If I had to guess I'd say you set it up like so:  
[http://wiki.apache.org/logging-log4j/SMTPAppender](http://wiki.apache.org/logging-log4j/SMTPAppender)  
but with the xml swapped for yaml.

BTW, you should be able to make a "code block" for thing like that yaml configuration by putting ``` above and below the text. It'll preserve whitespace and might even try for some syntax highlighting.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:50pm UTC](https://discuss.elastic.co/t/send-error-logs-by-email-smtp-appender/29387/3 "2017-07-05T23:50:01Z")

</div>


