Skip to content

Commit

Permalink
add logback
Browse files Browse the repository at this point in the history
  • Loading branch information
aruis committed Feb 3, 2019
1 parent 2668f22 commit f10b0b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ dependencies {

implementation "io.vertx:vertx-core:$vertxVersion"

compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile group: 'org.slf4j', name: 'jul-to-slf4j', version: '1.7.25'

testImplementation "io.vertx:vertx-junit5:$vertxVersion"
testRuntime("org.junit.jupiter:junit-jupiter-engine:$junitJupiterEngineVersion")
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/aruistar/vertxstarter/MainVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MainVerticle extends AbstractVerticle {

private static Logger logger = LoggerFactory.getLogger(MainVerticle.class);

@Override
public void start(Future<Void> startFuture) throws Exception {
logger.info("verticle start");
vertx.createHttpServer().requestHandler(req -> {
req.response()
.putHeader("content-type", "text/plain")
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</encoder>
</appender>

<logger name="com.aruistar" level="info"/>

<root level="info">
<appender-ref ref="STDOUT" />
</root>

</configuration>

0 comments on commit f10b0b0

Please sign in to comment.