Skip to content

Commit 336b570

Browse files
authored
Merge pull request #92 from navikt/task/sikkerlogg
Enable secure logs for inntekt-api
2 parents 85606fa + a05f7e4 commit 336b570

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

nais/base/nais.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ spec:
2626
memory: 256Mi
2727
vault:
2828
enabled: true
29+
secureLogs:
30+
enabled: true

src/main/kotlin/no/nav/dagpenger/inntekt/InntektApi.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import no.nav.dagpenger.oidc.StsOidcClient
6161
import org.slf4j.event.Level
6262

6363
private val LOGGER = KotlinLogging.logger {}
64+
private val sikkerLogg = KotlinLogging.logger("tjenestekall")
6465
val config = Configuration()
6566

6667
fun main() = runBlocking {
@@ -210,7 +211,8 @@ fun Application.inntektApi(
210211
if (HttpStatusCode.fromValue(cause.status).isSuccess()) HttpStatusCode.InternalServerError else HttpStatusCode.fromValue(
211212
cause.status
212213
)
213-
LOGGER.error("Request failed against inntektskomponenten", cause)
214+
sikkerLogg.error(cause) { "Request failed against inntektskomponenten" }
215+
LOGGER.error("Request failed against inntektskomponenten")
214216
val error = Problem(
215217
type = URI("urn:dp:error:inntektskomponenten"),
216218
title = "Innhenting av inntekt mot a-inntekt feilet. Prøv igjen senere",

src/main/resources/log4j2.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,23 @@
88
stackTraceEnabled="true"/>
99
</Console>
1010
<Prometheus name="metrics"/>
11+
12+
<RollingFile name="securelog" filename="/Users/l153963/secure-logs/secure.log" filePattern="/Users/l153963/secure-logs/secure.log.%i" append="true">
13+
<LogstashLayout dateTimeFormatPattern="yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
14+
eventTemplateUri="classpath:LogstashJsonEventLayoutV1.json"
15+
prettyPrintEnabled="false"
16+
stackTraceEnabled="true"/>
17+
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
18+
<Policies>
19+
<SizeBasedTriggeringPolicy size="25MB" />
20+
</Policies>
21+
<DefaultRolloverStrategy max="5"/>
22+
</RollingFile>
1123
</Appenders>
1224
<Loggers>
25+
<Logger name="tjenestekall" level="debug" includeLocation="true">
26+
<AppenderRef ref="securelog"/>
27+
</Logger>
1328
<Root level="info">
1429
<AppenderRef ref="ConsoleAppender"/>
1530
<AppenderRef ref="metrics"/>

0 commit comments

Comments
 (0)