Send ERROR logs by email - SMTP appender


(Emanuel Buzek) #1

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
host: 192.168.42.7
to: bugs@xyz.com
subject: "ES LOG"

Thanks in advance for suggestions / working solutions.


related threads:



(Nik Everett) #2

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

If I had to guess I'd say you set it up like so:
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.


(system) #3