Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples/logging/logback-aot to use Nima #6866

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/logging/logback-aot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Within 30 seconds the configuration should be reloaded, and next request will ha

Expected output should be similar to the following (for both hotspot and native):
```text
15:40:44.240 INFO [main] i.h.examples.logging.slf4j.Main - Starting up startup
15:40:44.241 INFO [main] i.h.examples.logging.slf4j.Main - Using JUL logger startup
15:40:44.245 INFO [pool-1-thread-1] i.h.examples.logging.slf4j.Main - Running on another thread propagated
15:40:44.395 INFO [features-thread] io.helidon.common.features.HelidonFeatures - Helidon SE 2.2.0 features: [Config, WebServer]
15:40:44.538 INFO [nioEventLoopGroup-2-1] io.helidon.reactive.webserver.NettyWebServer - Channel '@default' started: [id: 0x8e516487, L:/0:0:0:0:0:0:0:0:8080]
15:40:44.240 [INFO ] [io.helidon.examples.logging.logback.aot.Main.logging:128] Starting up startup
15:40:44.241 [INFO ] [o.slf4j.jdk.platform.logging.SLF4JPlatformLogger.performLog:151] Using System logger startup
15:40:44.245 [INFO ] [io.helidon.examples.logging.logback.aot.Main.log:146] Running on another thread propagated
15:40:44.395 [INFO ] [o.slf4j.jdk.platform.logging.SLF4JPlatformLogger.performLog:151] Helidon NIMA 4.0.0-SNAPSHOT features: [Config, Encoding, Media, WebServer]
15:40:44.538 [INFO ] [o.slf4j.jdk.platform.logging.SLF4JPlatformLogger.performLog:151] Started all channels in 15 milliseconds. 647 milliseconds since JVM startup. Java 20.0.1+9-29 propagated
```

The output is also logged into `helidon.log`.
Expand All @@ -36,7 +36,7 @@ mvn clean package

Run from command line:
```shell script
java -jar target/helidon-examples-logging-sfl4j.jar
java -jar target/helidon-examples-logging-slf4j-aot.jar
```

Execute endpoint:
Expand Down
4 changes: 2 additions & 2 deletions examples/logging/logback-aot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

<dependencies>
<dependency>
<groupId>io.helidon.reactive.webserver</groupId>
<artifactId>helidon-reactive-webserver</artifactId>
<groupId>io.helidon.nima.webserver</groupId>
<artifactId>helidon-nima-webserver</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.logging</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,13 +19,12 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import io.helidon.common.context.Context;
import io.helidon.common.context.Contexts;
import io.helidon.logging.common.HelidonMdc;
import io.helidon.reactive.webserver.Routing;
import io.helidon.reactive.webserver.WebServer;
import io.helidon.nima.webserver.WebServer;
import io.helidon.nima.webserver.http.HttpRouting;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
Expand Down Expand Up @@ -60,20 +59,20 @@ public static void main(String[] args) {
// done by the webserver
Contexts.runInContext(Context.create(), Main::logging);

WebServer.builder()
.routing(Routing.builder()
.get("/", (req, res) -> {
HelidonMdc.set("name", String.valueOf(req.requestId()));
LOGGER.debug("Debug message to show runtime reloading works");
LOGGER.info("Running in webserver, id:");
res.send("Hello")
.forSingle(ignored -> LOGGER.debug("Response sent"));
})
.build())
WebServer server = WebServer.builder()
.port(8080)
.build()
.start()
.await(10, TimeUnit.SECONDS);
.routing(Main::routing)
.start();
}

private static void routing(HttpRouting.Builder routing) {
routing.get("/", (req, res) -> {
HelidonMdc.set("name", String.valueOf(req.id()));
LOGGER.debug("Debug message to show runtime reloading works");
LOGGER.info("Running in webserver, id:");
res.send("Hello");
LOGGER.debug("Response sent");
});
}

private static void setupLogging() {
Expand Down