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/jul to use Nima #6865

Merged
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
6 changes: 3 additions & 3 deletions examples/logging/jul/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ java -jar target/helidon-examples-logging-jul.jar

Expected output should be similar to the following:
```text
2020.11.19 15:37:28 INFO io.helidon.logging.common.LogConfig Thread[main,5,main]: Logging at initialization configured using classpath: /logging.properties ""
2020.11.19 15:37:28 INFO io.helidon.logging.jul.JulProvider Thread[#1,main,5,main]: Logging at initialization configured using classpath: /logging.properties ""
2020.11.19 15:37:28 INFO io.helidon.examples.logging.jul.Main Thread[main,5,main]: Starting up "startup"
2020.11.19 15:37:28 INFO io.helidon.examples.logging.jul.Main Thread[pool-1-thread-1,5,main]: Running on another thread "propagated"
2020.11.19 15:37:28 INFO io.helidon.common.features.HelidonFeatures Thread[features-thread,5,main]: Helidon SE 2.2.0 features: [Config, WebServer] ""
2020.11.19 15:37:28 INFO io.helidon.reactive.webserver.NettyWebServer Thread[nioEventLoopGroup-2-1,10,main]: Channel '@default' started: [id: 0x8a5f5634, L:/0:0:0:0:0:0:0:0:8080] ""
2020.11.19 15:37:28 INFO io.helidon.common.features.HelidonFeatures Thread[#23,features-thread,5,main]: Helidon NIMA 4.0.0-SNAPSHOT features: [Config, Encoding, Media, WebServer] ""
2020.11.19 15:37:28 INFO io.helidon.nima.webserver.LoomServer Thread[#1,main,5,main]: Started all channels in 46 milliseconds. 577 milliseconds since JVM startup. Java 20.0.1+9-29 "propagated"
```

# Running as native image
Expand Down
4 changes: 2 additions & 2 deletions examples/logging/jul/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,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>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 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,15 +19,14 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

import io.helidon.common.context.Context;
import io.helidon.common.context.Contexts;
import io.helidon.logging.common.HelidonMdc;
import io.helidon.logging.common.LogConfig;
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;

/**
* Main class of the example, runnable from command line.
Expand All @@ -51,18 +50,18 @@ 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.info("Running in webserver, id:");
res.send("Hello");
})
.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.info("Running in webserver, id:");
res.send("Hello");
});
}

private static void logging() {
Expand Down