-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from devatherock/logback-env-variable
feat: Added environment variable to accept logback config path
- Loading branch information
Showing
7 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
package io.github.devatherock; | ||
|
||
import org.slf4j.LoggerFactory; | ||
|
||
import ch.qos.logback.classic.LoggerContext; | ||
import ch.qos.logback.classic.joran.JoranConfigurator; | ||
import ch.qos.logback.classic.util.ContextInitializer; | ||
import ch.qos.logback.core.joran.spi.JoranException; | ||
import ch.qos.logback.core.util.StatusPrinter; | ||
import io.micronaut.runtime.Micronaut; | ||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.annotations.servers.Server; | ||
|
||
@OpenAPIDefinition(info = @Info(title = "artifactory-badge", version = "0.5.0"), servers = { | ||
@OpenAPIDefinition(info = @Info(title = "artifactory-badge", version = "1.0.0"), servers = { | ||
@Server(url = "http://localhost:8080", description = "The server where the application is hosted. Defaulted to localhost") | ||
}) | ||
public class Application { | ||
private static final String ENV_LOGBACK_CONFIG = "LOGBACK_CONFIGURATION_FILE"; | ||
|
||
public static void main(String[] args) { | ||
if (System.getProperty(ContextInitializer.CONFIG_FILE_PROPERTY) == null && | ||
System.getenv(ENV_LOGBACK_CONFIG) != null) { | ||
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); | ||
|
||
try { | ||
JoranConfigurator configurator = new JoranConfigurator(); | ||
configurator.setContext(context); | ||
context.reset(); | ||
configurator.doConfigure( | ||
Application.class.getClassLoader().getResourceAsStream(System.getenv( | ||
ENV_LOGBACK_CONFIG))); | ||
} catch (JoranException je) { | ||
// StatusPrinter will handle this | ||
} | ||
StatusPrinter.printInCaseOfErrorsOrWarnings(context); | ||
} | ||
|
||
Micronaut.run(Application.class); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ces/META-INF/native-image/io.github.devatherock/artifactory-badge/native-image.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
{ | ||
"name": "net.logstash.logback.encoder.LogstashEncoder", | ||
"allDeclaredFields": true, | ||
"allDeclaredMethods": true, | ||
"allDeclaredConstructors": true | ||
} | ||
] |