release/0.9.0: Upgraded logging feature
·
10 commits
to master
since this release
Upgrade ktor to version 1.5.1 or newer.
Added new ApplicationCallLogging feature with correct logging request body.
Now ApplicationCallLogging logging all raw request body (except multipart data, it is not support for now).
Now before send it hides secret fields value in request body, headers and query parameters (default field list: "password", "token", "authorization"). To change field list pass them to the function applyDefaultLogging in install ApplicationCallLogging feature, for example:
install(ApplicationCallLogging) {
applyDefaultLogging(secretFieldList = listOf("field1", "field2"))
// Log only /api requests
// filter { call -> call.request.path().startsWith("/api") }
}Migration guide:
- Replace io.ktor.features.CallLogging to com.icerockdev.webserver.log.ApplicationCallLogging
Before:
install(CallLogging) {
applyDefaultLogging()
// Log only /api requests
// filter { call -> call.request.path().startsWith("/api") }
}After:
install(ApplicationCallLogging) {
applyDefaultLogging()
// Log only /api requests
// filter { call -> call.request.path().startsWith("/api") }
}- Remove mapper property in install StatusPages and rename funtion applyStatusConfiguration to applyDefaultStatusConfiguration
Before:
install(StatusPages) {
applyStatusConfiguration(
logger = LoggerFactory.getLogger(Application::class.java),
mapper = jacksonObjectMapper().apply {
applyDefaultConfiguration()
applyPrettyPrintConfiguration()
}
)
}After:
install(StatusPages) {
applyDefaultStatusConfiguration(
logger = LoggerFactory.getLogger(Application::class.java)
)
}- Remove requestTypes property for LoggingConfiguration in install JsonDataLogger
Before:
install(JsonDataLogger) {
mapperConfiguration = {
applyDefaultConfiguration()
applyPrettyPrintConfiguration()
applyJsonSecretConfiguration()
}
loggingConfiguration =
LoggingConfiguration(
responseTypes = listOf(AbstractResponse::class, CustomResponse::class),
requestTypes = listOf(Request::class)
)
}After:
install(JsonDataLogger) {
mapperConfiguration = {
applyDefaultConfiguration()
applyPrettyPrintConfiguration()
applyJsonSecretConfiguration()
}
loggingConfiguration =
LoggingConfiguration(
responseTypes = listOf(AbstractResponse::class, CustomResponse::class)
)
}