Skip to content

Commit

Permalink
feat: added logging.properties and gradle config to enable Helidon lo…
Browse files Browse the repository at this point in the history
…gging

Signed-off-by: Matt Peterson <[email protected]>
  • Loading branch information
mattp-swirldslabs committed Sep 3, 2024
1 parent 3c61790 commit b373c30
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gradle/modules.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ com.lmax.disruptor=com.lmax:disruptor
io.helidon.webserver=io.helidon.webserver:helidon-webserver
io.helidon.webserver.grpc=io.helidon.webserver:helidon-webserver-grpc
io.helidon.webserver.testing.junit5=io.helidon.webserver.testing.junit5:helidon-webserver-testing-junit5

io.helidon.logging=io.helidon.logging:helidon-logging-jul
org.antlr.antlr4.runtime=org.antlr:antlr4-runtime
com.google.common=com.google.guava:guava

Expand Down
1 change: 1 addition & 0 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mainModuleInfo {
annotationProcessor("com.google.auto.service.processor")
runtimeOnly("com.swirlds.config.impl")
runtimeOnly("org.apache.logging.log4j.slf4j2.impl")
runtimeOnly("io.helidon.logging")
}

testModuleInfo {
Expand Down
3 changes: 3 additions & 0 deletions server/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ COPY --from=distributions server-${VERSION}.tar .
# Extract the TAR file
RUN tar -xvf server-${VERSION}.tar

# Copy the logging properties file
COPY logging.properties logging.properties

# RUN the bin script for starting the server
ENTRYPOINT ["/bin/bash", "-c", "/app/server-${VERSION}/bin/server"]
32 changes: 32 additions & 0 deletions server/docker/logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Log Level Values
#
# SEVERE: indicates a critical error or failure
# WARNING: warns of potential issues or errors
# INFO: reports normal operational information
# CONFIG: provides configuration-related information
# FINE: provides detailed debugging information
# FINER: provides finer-grained debugging information
# FINEST: provides the most detailed debugging information

# Set the default logging level
.level=INFO

# Helidon loggers
io.helidon.webserver.level=SEVERE
io.helidon.config.level=SEVERE
io.helidon.security.level=INFO
io.helidon.common.level=INFO

# Configure the app log level
#com.hedera.block.level=FINE
#com.hedera.block.server.level=FINE

# Configure specific loggers
#com.hedera.block.server.mediator.LiveStreamMediatorImpl.level=FINE
#com.hedera.block.server.persistence.storage.write.BlockAsDirWriter.level=FINE
#com.hedera.block.server.producer.ProducerBlockItemObserver.level=FINE

# Console handler configuration
handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
6 changes: 6 additions & 0 deletions server/src/main/java/com/hedera/block/server/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ private Constants() {}
/** Constant mapped to the application.properties file in resources with default values */
@NonNull public static final String APPLICATION_PROPERTIES = "app.properties";

/**
* Constant mapped to the Helidon logging.properties file in the docker directory with default
* values.
*/
@NonNull public static final String LOGGING_PROPERTIES = "logging.properties";

/** Constant mapped to the name of the service in the .proto file */
@NonNull public static final String SERVICE_NAME = "BlockStreamService";

Expand Down
17 changes: 14 additions & 3 deletions server/src/main/java/com/hedera/block/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package com.hedera.block.server;

import static com.hedera.block.server.Constants.APPLICATION_PROPERTIES;
import static com.hedera.block.server.Constants.LOGGING_PROPERTIES;
import static io.helidon.config.ConfigSources.file;
import static java.lang.System.Logger;
import static java.lang.System.Logger.Level.INFO;

Expand All @@ -24,8 +27,10 @@
import com.swirlds.config.extensions.sources.ClasspathFileConfigSource;
import com.swirlds.config.extensions.sources.SystemEnvironmentConfigSource;
import com.swirlds.config.extensions.sources.SystemPropertiesConfigSource;
import io.helidon.config.Config;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

/** Main class for the block node server */
public class Server {
Expand All @@ -43,14 +48,20 @@ private Server() {}
public static void main(final String[] args) throws IOException {
LOGGER.log(INFO, "Starting BlockNode Server");

// Set the global configuration
final Config config =
Config.builder()
.sources(file(Paths.get("/app", LOGGING_PROPERTIES)).optional())
.build();

Config.global(config);

// Init BlockNode Configuration
Configuration configuration =
ConfigurationBuilder.create()
.withSource(SystemEnvironmentConfigSource.getInstance())
.withSource(SystemPropertiesConfigSource.getInstance())
.withSource(
new ClasspathFileConfigSource(
Path.of(Constants.APPLICATION_PROPERTIES)))
.withSources(new ClasspathFileConfigSource(Path.of(APPLICATION_PROPERTIES)))
.autoDiscoverExtensions()
.build();

Expand Down
1 change: 1 addition & 0 deletions server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
requires dagger;
requires io.grpc.stub;
requires io.helidon.common;
requires io.helidon.config;
requires io.helidon.webserver.grpc;
requires io.helidon.webserver;
requires javax.inject;
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencyResolutionManagement {
// Compile time dependencies
version("io.helidon.webserver.http2", "4.1.0")
version("io.helidon.webserver.grpc", "4.1.0")
version("io.helidon.logging", "4.1.0")
version("com.lmax.disruptor", "4.0.0")
version("com.github.spotbugs.annotations", "4.7.3")
version("com.swirlds.metrics.api", swirldsVersion)
Expand Down

0 comments on commit b373c30

Please sign in to comment.