Class SmtpManager
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.AbstractManager
-
- org.apache.logging.log4j.core.net.SmtpManager
-
- All Implemented Interfaces:
AutoCloseable
public class SmtpManager extends AbstractManager
Manager for sending SMTP events.
-
-
Field Summary
-
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count, LOGGER
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SmtpManager(String name, javax.mail.Session session, javax.mail.internet.MimeMessage message, org.apache.logging.log4j.core.net.SmtpManager.FactoryData data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(LogEvent event)
protected void
encodeContent(byte[] bytes, String encoding, ByteArrayOutputStream out)
protected byte[]
encodeContentToBytes(byte[] rawBytes, String encoding)
protected byte[]
formatContentToBytes(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout)
protected String
getEncoding(byte[] rawBytes, String contentType)
protected javax.mail.internet.InternetHeaders
getHeaders(String contentType, String encoding)
protected javax.mail.internet.MimeMultipart
getMimeMultipart(byte[] encodedBytes, javax.mail.internet.InternetHeaders headers)
static SmtpManager
getSmtpManager(Configuration config, String to, String cc, String bcc, String from, String replyTo, String subject, String protocol, String host, int port, String username, String password, boolean isDebug, String filterName, int numElements, SslConfiguration sslConfiguration)
void
sendEvents(Layout<?> layout, LogEvent appendEvent)
Send the contents of the cyclic buffer as an e-mail message.protected void
sendMultipartMessage(javax.mail.internet.MimeMessage msg, javax.mail.internet.MimeMultipart mp)
protected void
writeBuffer(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout, OutputStream out)
protected void
writeFooter(Layout<?> layout, OutputStream out)
protected void
writeHeader(Layout<?> layout, OutputStream out)
-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
close, getContentFormat, getCount, getLoggerContext, getManager, getName, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, releaseSub, stop, updateData
-
-
-
-
Constructor Detail
-
SmtpManager
protected SmtpManager(String name, javax.mail.Session session, javax.mail.internet.MimeMessage message, org.apache.logging.log4j.core.net.SmtpManager.FactoryData data)
-
-
Method Detail
-
add
public void add(LogEvent event)
-
getSmtpManager
public static SmtpManager getSmtpManager(Configuration config, String to, String cc, String bcc, String from, String replyTo, String subject, String protocol, String host, int port, String username, String password, boolean isDebug, String filterName, int numElements, SslConfiguration sslConfiguration)
-
sendEvents
public void sendEvents(Layout<?> layout, LogEvent appendEvent)
Send the contents of the cyclic buffer as an e-mail message.- Parameters:
layout
- The layout for formatting the events.appendEvent
- The event that triggered the send.
-
formatContentToBytes
protected byte[] formatContentToBytes(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout) throws IOException
- Throws:
IOException
-
writeHeader
protected void writeHeader(Layout<?> layout, OutputStream out) throws IOException
- Throws:
IOException
-
writeBuffer
protected void writeBuffer(LogEvent[] priorEvents, LogEvent appendEvent, Layout<?> layout, OutputStream out) throws IOException
- Throws:
IOException
-
writeFooter
protected void writeFooter(Layout<?> layout, OutputStream out) throws IOException
- Throws:
IOException
-
encodeContentToBytes
protected byte[] encodeContentToBytes(byte[] rawBytes, String encoding) throws javax.mail.MessagingException, IOException
- Throws:
javax.mail.MessagingException
IOException
-
encodeContent
protected void encodeContent(byte[] bytes, String encoding, ByteArrayOutputStream out) throws javax.mail.MessagingException, IOException
- Throws:
javax.mail.MessagingException
IOException
-
getHeaders
protected javax.mail.internet.InternetHeaders getHeaders(String contentType, String encoding)
-
getMimeMultipart
protected javax.mail.internet.MimeMultipart getMimeMultipart(byte[] encodedBytes, javax.mail.internet.InternetHeaders headers) throws javax.mail.MessagingException
- Throws:
javax.mail.MessagingException
-
sendMultipartMessage
protected void sendMultipartMessage(javax.mail.internet.MimeMessage msg, javax.mail.internet.MimeMultipart mp) throws javax.mail.MessagingException
- Throws:
javax.mail.MessagingException
-
-