# Log4j: Configuring SMTPAppender

**URL:** <https://discuss.elastic.co/t/log4j-configuring-smtpappender/22045>\
**Category:** Elasticsearch\
**Created:** [February 9, 2015, 2:31pm UTC](https://discuss.elastic.co/t/log4j-configuring-smtpappender/22045 "2015-02-09T14:31:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abid\_Hussain](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Abid\_Hussain](https://discuss.elastic.co/u/Abid_Hussain)\
**Post date:** [February 9, 2015, 2:31pm UTC](https://discuss.elastic.co/t/log4j-configuring-smtpappender/22045/1 "2015-02-09T14:31:01Z")

</div>

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:  
...

appender:  
console:  
....  
email:  
type: smtp  
smtpHost: my.smtp.host  
from: [es@example.net](mailto:es@example.net)  
to: [admin@example.net](mailto:admin@example.net)  
subject: ElasticSearch Warning  
layout:  
type: pattern  
conversionPattern: .....

So, does anybody have a working example to do so?

Regards,

Abid

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/58c92f42-0046-453e-add0-3b726cafa822%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/58c92f42-0046-453e-add0-3b726cafa822%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Abid\_Hussain](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Abid\_Hussain](https://discuss.elastic.co/u/Abid_Hussain)\
**Post date:** [February 10, 2015, 10:15am UTC](https://discuss.elastic.co/t/log4j-configuring-smtpappender/22045/2 "2015-02-10T10:15:38Z")

</div>

Just for evaluation purposes, I tried to configure a simple  
logging.properties in $ES\_HOME/config but not even this had any success.

log4j.rootLogger=DEBUG, A1

log4j.appender.A1=org.apache.log4j.RollingFileAppender  
log4j.appender.A1.File=/home/my\_user/elasticsearch.log  
log4j.appender.A1.MaxFileSize=40000KB  
log4j.appender.A1.MaxBackupIndex=5  
log4j.appender.A1.layout=org.apache.log4j.PatternLayout  
log4j.appender.A1.layout.ConversionPattern=[%d{ISO8601}][%-5p][%-25c] %m%n  
log4j.appender.A1.Encoding=UTF-8

No file /home/my\_user/elasticsearch.log is being created when starting  
elasticsearch (directory /home/my\_user exists) and I have no idea what I'm  
doing wrong... ☹

Regards,

Abid

Am Montag, 9. Februar 2015 15:31:01 UTC+1 schrieb Abid Hussain:

> 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:  
> ...
> 
> appender:  
> console:  
> ....  
> email:  
> type: smtp  
> smtpHost: my.smtp.host  
> from: [es@example.net](mailto:es@example.net)  
> to: [admin@example.net](mailto:admin@example.net)  
> subject: Elasticsearch Warning  
> layout:  
> type: pattern  
> conversionPattern: .....
> 
> So, does anybody have a working example to do so?
> 
> Regards,
> 
> Abid

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d50ebd43-6c92-473c-b5f2-491623b4b093%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d50ebd43-6c92-473c-b5f2-491623b4b093%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:33am UTC](https://discuss.elastic.co/t/log4j-configuring-smtpappender/22045/3 "2017-07-06T00:33:57Z")

</div>


