Merge pull request #8370 from shubhi22/BAEL-3500-logback-email

BAEL-3500 Emails with Logback
This commit is contained in:
Eric Martin 2019-12-28 12:44:10 -06:00 committed by GitHub
commit f4ff0da44a
2 changed files with 51 additions and 0 deletions

View File

@ -50,12 +50,25 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>${javax.activation.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<logback.version>1.2.3</logback.version>
<logback.contrib.version>0.1.5</logback.contrib.version>
<docx4j.version>3.3.5</docx4j.version>
<javax.mail.version>1.4.7</javax.mail.version>
<javax.activation.version>1.1.1</javax.activation.version>
</properties>
</project>

View File

@ -10,9 +10,47 @@
</encoder>
</appender>
<appender name="emailAppender" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>OUR-SMTP-HOST-ADDRESS</smtpHost>
<!-- one or more recipients are possible -->
<to>EMAIL-RECIPIENT-1</to>
<to>EMAIL-RECIPIENT-2</to>
<from>SENDER-EMAIL-ADDRESS</from>
<subject>BAELDUNG: %logger{20} - %msg</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n</pattern>
</layout>
</appender>
<appender name="emailAppenderCustomBufferSize" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>OUR-SMTP-HOST-ADDRESS</smtpHost>
<to>EMAIL-RECIPIENT</to>
<from>SENDER-EMAIL-ADDRESS</from>
<subject>BAELDUNG: %logger{20} - %msg</subject>
<layout class="ch.qos.logback.classic.html.HTMLLayout"/>
<cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker">
<!-- only 5 log entries on email -->
<bufferSize>5</bufferSize>
</cyclicBufferTracker>
</appender>
<appender name="emailAppenderGmail" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>smtp.gmail.com</smtpHost>
<smtpPort>587</smtpPort>
<STARTTLS>true</STARTTLS>
<asynchronousSending>false</asynchronousSending>
<username>SENDER-EMAIL@gmail.com</username>
<password>GMAIL-ACCT-PASSWORD</password>
<to>EMAIL-RECIPIENT</to>
<from>SENDER-EMAIL@gmail.com</from>
<subject>BAELDUNG: %logger{20} - %msg</subject>
<layout class="ch.qos.logback.classic.html.HTMLLayout"/>
</appender>
<root level="info">
<appender-ref ref="map"/>
<appender-ref ref="out"/>
<appender-ref ref="emailAppender"/>
</root>
</configuration>