Skip to content

Commit 3532b76

Browse files
authored
Merge pull request #1365 from navikt/less-logging
Less logging
2 parents 49702bf + 7fdfb40 commit 3532b76

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package no.nav.klage.oppgave.config
2+
3+
import ch.qos.logback.classic.Level
4+
import ch.qos.logback.classic.Logger
5+
import ch.qos.logback.classic.turbo.TurboFilter
6+
import ch.qos.logback.core.spi.FilterReply
7+
import no.nav.klage.oppgave.util.getLogger
8+
import org.slf4j.Marker
9+
10+
class InternalLogFilter : TurboFilter() {
11+
12+
companion object {
13+
@Suppress("JAVA_CLASS_ON_COMPANION")
14+
private val ourLogger = getLogger(javaClass.enclosingClass)
15+
}
16+
17+
override fun decide(
18+
marker: Marker?,
19+
logger: Logger?,
20+
level: Level?,
21+
format: String?,
22+
params: Array<out Any>?,
23+
throwable: Throwable?
24+
): FilterReply {
25+
if (level == Level.DEBUG && logger?.name == "org.springframework.web.filter.CommonsRequestLoggingFilter" &&
26+
(format?.contains("request [GET /internal/prometheus") == true ||
27+
format?.contains("request [GET /internal/health") == true)
28+
) {
29+
return FilterReply.DENY
30+
}
31+
32+
return FilterReply.NEUTRAL
33+
}
34+
}

src/main/resources/application.yml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ spring:
88
add-mappings: false
99
mvc:
1010
throw-exception-if-no-handler-found: true
11-
log-request-details: true
1211
datasource:
1312
url: jdbc:postgresql://${NAIS_DATABASE_KABAL_API_KABAL_API_HOST}:${NAIS_DATABASE_KABAL_API_KABAL_API_PORT}/${NAIS_DATABASE_KABAL_API_KABAL_API_DATABASE}
1413
username: ${NAIS_DATABASE_KABAL_API_KABAL_API_USERNAME}

src/main/resources/logback-spring.xml

+3-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
44

55
<turboFilter class="no.nav.klage.oppgave.config.SseBrokenPipeLogFilter" />
6+
<turboFilter class="no.nav.klage.oppgave.config.InternalLogFilter" />
67

78
<springProfile name="local">
89
<appender name="text" class="ch.qos.logback.core.ConsoleAppender">
@@ -46,10 +47,8 @@
4647
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
4748
<fileNamePattern>/secure-logs/secure.log.%d{yyyy-MM-dd}.%i</fileNamePattern>
4849
<maxHistory>30</maxHistory>
49-
<minIndex>1</minIndex>
50-
<maxIndex>4</maxIndex>
51-
<maxFileSize>30MB</maxFileSize>
52-
<totalSizeCap>115MB</totalSizeCap>
50+
<maxFileSize>26MB</maxFileSize>
51+
<totalSizeCap>100MB</totalSizeCap>
5352
</rollingPolicy>
5453
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
5554
</appender>
@@ -70,18 +69,10 @@
7069
<appender-ref ref="secureJson"/>
7170
</logger>
7271

73-
<logger name="org.springframework.web.servlet.DispatcherServlet" level="trace" additivity="false">
74-
<appender-ref ref="secureJson"/>
75-
</logger>
76-
7772
<logger name="reactor.netty.http.client" level="debug" additivity="false">
7873
<appender-ref ref="secureJson"/>
7974
</logger>
8075

81-
<logger name="org.springframework.data.elasticsearch.client" level="trace" additivity="false">
82-
<appender-ref ref="secureJson"/>
83-
</logger>
84-
8576
<logger name="org.springframework.data.convert.CustomConversions" level="error"/>
8677

8778
<logger name="no.nav.security.token.support" level="debug" additivity="false">

0 commit comments

Comments
 (0)