Skip to content

Commit

Permalink
#43 default logging impl as optional dependency, removing old lib fil…
Browse files Browse the repository at this point in the history
…e, adding some logging statements
  • Loading branch information
bbottema committed Jun 17, 2016
1 parent cff1dbc commit 3777210
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
Binary file removed lib/log4j-1.2.15.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,19 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId><!-- or log4j2 or logback or whatever-->
<version>2.6.1</version>
<scope>optional</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6.1</version>
<scope>optional</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.1</version>
<scope>optional</scope>
</dependency>

<!-- core dependencies -->
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/org/simplejavamail/Mailer.java
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public void run() {
}

private void sendMailClosure(Email email) {
LOGGER.trace("sending email...");
try {
// fill and send wrapped mime message parts
MimeMessage message = produceMimeMessage(email, session);
Expand All @@ -374,17 +375,20 @@ private void sendMailClosure(Email email) {

try {
if (proxyServer != null) {
LOGGER.trace("starting proxy bridge");
proxyServer.start();
}
try {
transport.connect();
transport.sendMessage(message, message.getAllRecipients());
} finally {
transport.connect();
transport.sendMessage(message, message.getAllRecipients());
} finally {
LOGGER.trace("closing transport");
//noinspection ThrowFromFinallyBlock
transport.close();
}
transport.close();
}
} finally {
if (proxyServer != null) {
LOGGER.trace("stopping proxy bridge");
proxyServer.stop();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress XmlUnboundNsPrefix -->
<configuration status="OFF">
<configuration status="INFO">
<appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss} [%t] %-5level %c{1} - %msg%n" />
Expand All @@ -17,7 +17,7 @@
</Logger>
<Logger name="org.codemonkey.simplejavamail.internal.socks" level="warn"/>

<Root level="warn">
<Root level="debug">
<AppenderRef ref="console" />
</Root>
</Loggers>
Expand Down

0 comments on commit 3777210

Please sign in to comment.