diff --git a/README.md b/README.md index 4d41ff73..71e90db2 100644 --- a/README.md +++ b/README.md @@ -217,13 +217,14 @@ On Windows, it's easier to run the server in docker while specifying the host as The standalone server supports the following configuration by `ENV` variables: -| Variable | Description | -|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `SERVER_HOSTNAME` | Lets the standalone server bind to a specific hostname, by default it binds to `0.0.0.0` | -| `SERVER_PORT` or `PORT` | The port that the standalone server will listen to, defaults to `8080`. The `PORT` environment variable may be used to [run the Docker image on Heroku](https://devcenter.heroku.com/articles/container-registry-and-runtime#pushing-an-existing-image) as per the documentation [here](https://devcenter.heroku.com/articles/setting-the-http-port-for-java-applications). | -| `JSON_CONFIG_PATH` | The absolute path to a json file containing configuration about the OAuth2 part of the server (`OAuth2Config`). More details on the format below. | -| `JSON_CONFIG` | The actual JSON content of `OAuth2Config`, this ENV var takes precedence over the `JSON_CONFIG_PATH` var. More details on the format below. | -| `LOG_LEVEL` | How verbose the root logging output is, defaults to `INFO` | +| Variable | Description | +|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `SERVER_HOSTNAME` | Lets the standalone server bind to a specific hostname, by default it binds to `0.0.0.0` | +| `SERVER_PORT` or `PORT` | The port that the standalone server will listen to, defaults to `8080`. The `PORT` environment variable may be used to [run the Docker image on Heroku](https://devcenter.heroku.com/articles/container-registry-and-runtime#pushing-an-existing-image) as per the documentation [here](https://devcenter.heroku.com/articles/setting-the-http-port-for-java-applications). | +| `JSON_CONFIG_PATH` | The absolute path to a json file containing configuration about the OAuth2 part of the server (`OAuth2Config`). More details on the format below. | +| `JSON_CONFIG` | The actual JSON content of `OAuth2Config`, this ENV var takes precedence over the `JSON_CONFIG_PATH` var. More details on the format below. | +| `LOG_LEVEL` | How verbose the root logging output is, defaults to `INFO` | +| `LOGBACK_CONFIG` | You can override the default logging config in [logback-standalone.xml](src/main/resources/logback-standalone.xml) with a path to your own logback xml file. | ##### JSON_CONFIG diff --git a/src/main/kotlin/no/nav/security/mock/oauth2/StandaloneMockOAuth2Server.kt b/src/main/kotlin/no/nav/security/mock/oauth2/StandaloneMockOAuth2Server.kt index 07aaeaab..8f89e076 100644 --- a/src/main/kotlin/no/nav/security/mock/oauth2/StandaloneMockOAuth2Server.kt +++ b/src/main/kotlin/no/nav/security/mock/oauth2/StandaloneMockOAuth2Server.kt @@ -1,15 +1,16 @@ package no.nav.security.mock.oauth2 +import ch.qos.logback.classic.ClassicConstants +import java.io.File +import java.io.FileNotFoundException +import java.net.InetAddress +import java.net.InetSocketAddress import no.nav.security.mock.oauth2.StandaloneConfig.hostname import no.nav.security.mock.oauth2.StandaloneConfig.oauth2Config import no.nav.security.mock.oauth2.StandaloneConfig.port import no.nav.security.mock.oauth2.http.NettyWrapper import no.nav.security.mock.oauth2.http.OAuth2HttpResponse import no.nav.security.mock.oauth2.http.route -import java.io.File -import java.io.FileNotFoundException -import java.net.InetAddress -import java.net.InetSocketAddress object StandaloneConfig { const val JSON_CONFIG = "JSON_CONFIG" @@ -47,6 +48,7 @@ object StandaloneConfig { } fun main() { + System.setProperty(ClassicConstants.CONFIG_FILE_PROPERTY, "LOGBACK_CONFIG".fromEnv("logback-standalone.xml")) MockOAuth2Server( oauth2Config(), route("/isalive") { diff --git a/src/main/resources/logback-standalone.xml b/src/main/resources/logback-standalone.xml new file mode 100644 index 00000000..28e82dd5 --- /dev/null +++ b/src/main/resources/logback-standalone.xml @@ -0,0 +1,17 @@ + + + + + + %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{70} - %msg%n + + + + + + + + + + + diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml deleted file mode 100644 index f44889fb..00000000 --- a/src/main/resources/logback.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{70} - %msg%n - - - - - - - - - - -