Add logging with log4j. Completes #40

This commit is contained in:
Colin McDonald 2016-07-11 23:54:21 -04:00
parent 38dec65bf9
commit f42f714863
3 changed files with 32 additions and 5 deletions

View File

@ -135,9 +135,14 @@
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
</dependency>

View File

@ -7,10 +7,6 @@ import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
final class Main {
public static void main(String[] args) {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "error");
System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
System.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "h:mm:ss a");
System.setProperty("org.slf4j.simpleLogger.showThreadName", "false");
System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory");
Vertx.vertx(new VertxOptions().setMetricsOptions(
new DropwizardMetricsOptions().setEnabled(true).setRegistryName("apiv3-registry")

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
<log4j:configuration>
<appender name="RollingAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="log/apiv3.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%p %d{yyyy-MM-dd HH:mm:ss}] %m%n"/>
</layout>
</appender>
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%p %d{yyyy-MM-dd HH:mm:ss}] %m%n"/>
</layout>
</appender>
<root>
<priority value="INFO"/>
<appender-ref ref="RollingAppender" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4j:configuration>