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:
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:
.…
1 Like
nik9000
(Nik Everett)
September 16, 2015, 1:16pm
2
It looks like smtp
is supposed to setup org.apache.log4j.net.SMTPAppender
:
.put("dailyRollingFile", "org.apache.log4j.DailyRollingFileAppender")
.put("externallyRolledFile", "org.apache.log4j.ExternallyRolledFileAppender")
.put("file", "org.apache.log4j.FileAppender")
.put("jdbc", "org.apache.log4j.jdbc.JDBCAppender")
.put("jms", "org.apache.log4j.net.JMSAppender")
.put("lf5", "org.apache.log4j.lf5.LF5Appender")
.put("ntevent", "org.apache.log4j.nt.NTEventLogAppender")
.put("null", "org.apache.log4j.NullAppender")
.put("rollingFile", "org.apache.log4j.RollingFileAppender")
.put("extrasRollingFile", "org.apache.log4j.rolling.RollingFileAppender")
.put("smtp", "org.apache.log4j.net.SMTPAppender")
.put("socket", "org.apache.log4j.net.SocketAppender")
.put("socketHub", "org.apache.log4j.net.SocketHubAppender")
.put("syslog", "org.apache.log4j.net.SyslogAppender")
.put("telnet", "org.apache.log4j.net.TelnetAppender")
// policies
.put("timeBased", "org.apache.log4j.rolling.TimeBasedRollingPolicy")
.put("sizeBased", "org.apache.log4j.rolling.SizeBasedTriggeringPolicy")
// layouts
.put("simple", "org.apache.log4j.SimpleLayout")
.put("html", "org.apache.log4j.HTMLLayout")
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.