I use graalvm to build a jar with tinylog and work very good! But when I use native-image build a exe,tinylog only work with default setting. what can I do let tinylog can load my tinylog.properties with native-image? please~ thanks!
Asked
Active
Viewed 193 times
2 Answers
0
On GitHub, you can find a minimal example project for using tinylog 2 in a native image build: https://github.com/tinylog-org/tinylog-graal-example
You need a custom Gradle task for generating the configuration for the native image (see tinylog-graal-example/blob/v2/build.gradle).
task generateConfiguration(type: Exec) {
group = "graal"
description = "Run application to generate the configuration for native image generation"
dependsOn jar, extractGraalTooling
commandLine project.gradle.gradleUserHomeDir.toPath().resolve("caches/com.palantir.graal/$graalVmVersion/graalvm-ce-$graalVmVersion/bin/java"), "-agentlib:native-image-agent=config-output-dir=" + project.buildDir.toPath().resolve("resources/main/META-INF/native-image"), "-cp", sourceSets.main.runtimeClasspath.getAsPath(), javaMainClass
doFirst {
mkdir project.buildDir.toPath().resolve("resources/main/META-INF/native-image")
}
}
Afterwards, you can run ./gradlew generateConfiguration
before ./gradlew nativeImage
for generating always the correct configuration.

Martin
- 598
- 1
- 4
- 27
-
I forget say .I use maven > – Yang Yang Feb 16 '22 at 10:21
-
IDK how to convert to maven version. and I don't see any sample. sorry – Yang Yang Feb 16 '22 at 10:22
0
thanks @Martin I try to move src\main\resources\tinylog.properties to src\main\resources\META-INF\native-image\tinylog.properties
regenerate properties with native-image-agent and rebuild native-image. Than it can load properties! thank !

Yang Yang
- 1
- 1