From 7f6e1fc6cb62e919d8efa1b956856bc5a1842a83 Mon Sep 17 00:00:00 2001 From: francescods Date: Thu, 27 Mar 2025 16:08:25 +0100 Subject: [PATCH 1/3] gestione rolling logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit di default ogni file di log è giornaliero e può essere al max 100MB. Il totale dei files di log può essere di 5GB e i files verranno cancellati ogni 15 giorni --- src/main/resources/logback.xml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 9714b07..1e12d8c 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,19 +1,43 @@ + + %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - ./logFile.log + + + + ./log/logFile.log true + + + + + ./log/logFile.%d{yyyy-MM-dd}.%i.log + + + 100MB + + + 15 + + + 5GB + + %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - + + + + + - \ No newline at end of file + + From 7b8eaa6261b9128a8d2d7043d91b6cbb1a8eef6c Mon Sep 17 00:00:00 2001 From: francescods Date: Thu, 27 Mar 2025 17:04:17 +0100 Subject: [PATCH 2/3] rimozione plugin CallLogging non utilizzato (usiamo logback) --- build.gradle.kts | 1 - src/main/kotlin/eu/maiora/Application.kt | 2 -- src/main/kotlin/eu/maiora/routes/Auth.kt | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index cef2a10..c18e3f7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,7 +33,6 @@ dependencies { //implementation("org.postgresql:postgresql:42.7.2") implementation("com.microsoft.sqlserver:mssql-jdbc:11.2.0.jre18") implementation("com.oracle.database.jdbc:ojdbc8:19.8.0.0") - implementation("io.ktor:ktor-server-call-logging:$ktor_version") implementation("io.ktor:ktor-server-cors:$ktor_version") implementation("org.jetbrains.exposed:exposed-jdbc:0.55.0") implementation("org.jetbrains.exposed:exposed-dao:$exposed_version") diff --git a/src/main/kotlin/eu/maiora/Application.kt b/src/main/kotlin/eu/maiora/Application.kt index 4e693fc..0b452d8 100644 --- a/src/main/kotlin/eu/maiora/Application.kt +++ b/src/main/kotlin/eu/maiora/Application.kt @@ -7,7 +7,6 @@ import io.ktor.server.application.* import io.ktor.server.config.* import io.ktor.server.engine.* import io.ktor.server.netty.* -import io.ktor.server.plugins.callloging.* import io.ktor.server.plugins.cors.routing.* import java.io.FileInputStream import java.util.* @@ -31,7 +30,6 @@ fun Application.module(configFile: Properties) { configureRouting() configureSerialization() - install(CallLogging) install(CORS){ anyHost() allowSameOrigin = true diff --git a/src/main/kotlin/eu/maiora/routes/Auth.kt b/src/main/kotlin/eu/maiora/routes/Auth.kt index 0443947..8460799 100644 --- a/src/main/kotlin/eu/maiora/routes/Auth.kt +++ b/src/main/kotlin/eu/maiora/routes/Auth.kt @@ -31,7 +31,7 @@ fun Route.auth(accountsRepository: AccountsRepositoryImpl) { logger.info( "param: " + receivedResponse.param - ); + ) // Decodifica la stringa da Base64 a oggetto Credentials val decodedBytes = Base64.getDecoder().decode(receivedResponse.param) From 0e061c9eca5eeefcbdba12ffa7eaf5c18ac7d3db Mon Sep 17 00:00:00 2001 From: francescods Date: Thu, 27 Mar 2025 17:35:19 +0100 Subject: [PATCH 3/3] ripristino plugin CallLogging permette di stampare nei log la risposta HTTP inviata da Ktor --- build.gradle.kts | 1 + src/main/kotlin/eu/maiora/Application.kt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index c18e3f7..cef2a10 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,6 +33,7 @@ dependencies { //implementation("org.postgresql:postgresql:42.7.2") implementation("com.microsoft.sqlserver:mssql-jdbc:11.2.0.jre18") implementation("com.oracle.database.jdbc:ojdbc8:19.8.0.0") + implementation("io.ktor:ktor-server-call-logging:$ktor_version") implementation("io.ktor:ktor-server-cors:$ktor_version") implementation("org.jetbrains.exposed:exposed-jdbc:0.55.0") implementation("org.jetbrains.exposed:exposed-dao:$exposed_version") diff --git a/src/main/kotlin/eu/maiora/Application.kt b/src/main/kotlin/eu/maiora/Application.kt index 0b452d8..4e693fc 100644 --- a/src/main/kotlin/eu/maiora/Application.kt +++ b/src/main/kotlin/eu/maiora/Application.kt @@ -7,6 +7,7 @@ import io.ktor.server.application.* import io.ktor.server.config.* import io.ktor.server.engine.* import io.ktor.server.netty.* +import io.ktor.server.plugins.callloging.* import io.ktor.server.plugins.cors.routing.* import java.io.FileInputStream import java.util.* @@ -30,6 +31,7 @@ fun Application.module(configFile: Properties) { configureRouting() configureSerialization() + install(CallLogging) install(CORS){ anyHost() allowSameOrigin = true