From 4f37d36e6006a88ee9798b39a63d88af181e675b Mon Sep 17 00:00:00 2001
From: ThanKarab <tkarabatsis@hotmail.com>
Date: Tue, 20 Oct 2020 14:07:33 +0300
Subject: [PATCH 1/5] Print logs on sysout not a file.

---
 docker/config/application.tmpl |  2 +-
 src/main/resources/logback.xml | 20 --------------------
 2 files changed, 1 insertion(+), 21 deletions(-)
 delete mode 100644 src/main/resources/logback.xml

diff --git a/docker/config/application.tmpl b/docker/config/application.tmpl
index 6174fb409..ae9d0f8fd 100644
--- a/docker/config/application.tmpl
+++ b/docker/config/application.tmpl
@@ -53,7 +53,7 @@ logging:
     root: {{ default .Env.LOG_LEVEL "INFO" }}
     org:
       springframework:
-        security: DEBUG
+        security: INFO
         web: {{ default .Env.LOGGING_LEVEL_WEB "WARN" }}
         web.servlet.handler.BeanNameUrlHandlerMapping: WARN
       hibernate: {{ default .Env.LOGGING_LEVEL_HIBERNATE "WARN" }}
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
deleted file mode 100644
index 0726d82f4..000000000
--- a/src/main/resources/logback.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<configuration>
-    <appender name="FILE1" class="ch.qos.logback.core.FileAppender">
-        <file>logs/portal-backend.txt</file>
-        <append>true</append>
-        <encoder>
-            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %msg%n</pattern>
-        </encoder>
-    </appender>
-
-	<logger name="eu.hbp.mip">
-		<appender-ref ref="FILE1" />
-	</logger>
-    <include resource="org/springframework/boot/logging/logback/base.xml"/>
-    <logger name="org.springframework.web" level="ERROR">
-		<appender-ref ref="FILE1" />
-	</logger>
-    <logger name="eu.hbp.mip.utils" level="INFO" additivity="false">
-        <appender-ref ref="FILE1" />
-    </logger>
-</configuration>
\ No newline at end of file
-- 
GitLab


From 9fc8560a24836d4f0cfa3f5e0c642a6141c8e9b2 Mon Sep 17 00:00:00 2001
From: ThanKarab <tkarabatsis@hotmail.com>
Date: Tue, 20 Oct 2020 14:15:31 +0300
Subject: [PATCH 2/5] Limit logs from spring framework.

---
 docker/config/application.tmpl | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/docker/config/application.tmpl b/docker/config/application.tmpl
index ae9d0f8fd..dce1ac742 100644
--- a/docker/config/application.tmpl
+++ b/docker/config/application.tmpl
@@ -53,10 +53,10 @@ logging:
     root: {{ default .Env.LOG_LEVEL "INFO" }}
     org:
       springframework:
-        security: INFO
-        web: {{ default .Env.LOGGING_LEVEL_WEB "WARN" }}
-        web.servlet.handler.BeanNameUrlHandlerMapping: WARN
-      hibernate: {{ default .Env.LOGGING_LEVEL_HIBERNATE "WARN" }}
+        security: ERROR
+        web: {{ default .Env.LOGGING_LEVEL_WEB "ERROR" }}
+        web.servlet.handler.BeanNameUrlHandlerMapping: ERROR
+      hibernate: {{ default .Env.LOGGING_LEVEL_HIBERNATE "ERROR" }}
     eu:
       hbp: {{ default .Env.LOGGING_LEVEL_MIP "INFO" }}
 
-- 
GitLab


From 8e21f0c6a047cf0cddb710cd633e3418217c3aca Mon Sep 17 00:00:00 2001
From: ThanKarab <tkarabatsis@hotmail.com>
Date: Fri, 23 Oct 2020 12:41:03 +0300
Subject: [PATCH 3/5] Removed curl installation because build was failing.

---
 Dockerfile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index a4fa1142f..458fbc8a3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,8 +14,7 @@ RUN cp /usr/share/maven/ref/settings-docker.xml /root/.m2/settings.xml \
 
 FROM hbpmip/java-base:11.0.1-1
 
-RUN apt-get update && apt-get install -y --no-install-recommends curl \
-    && rm -rf /var/lib/apt/lists/* /tmp/*
+RUN rm -rf /var/lib/apt/lists/* /tmp/*
 
 COPY docker/config/application.tmpl /opt/portal/config/application.tmpl
 COPY docker/README.md docker/run.sh /opt/portal/
-- 
GitLab


From 6a75260e9d224c33447b6246065ef0da887d2e62 Mon Sep 17 00:00:00 2001
From: ThanKarab <tkarabatsis@hotmail.com>
Date: Fri, 23 Oct 2020 13:08:02 +0300
Subject: [PATCH 4/5] Reduced logs and removed spacing.

---
 docker/config/application.tmpl                   |  2 +-
 .../mip/configuration/SecurityConfiguration.java |  2 --
 src/main/java/eu/hbp/mip/utils/Logging.java      | 16 ----------------
 3 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/docker/config/application.tmpl b/docker/config/application.tmpl
index dce1ac742..8d76148db 100644
--- a/docker/config/application.tmpl
+++ b/docker/config/application.tmpl
@@ -50,7 +50,7 @@ frontend:
   
 logging:
   level:
-    root: {{ default .Env.LOG_LEVEL "INFO" }}
+    root: {{ default .Env.LOG_LEVEL "ERROR" }}
     org:
       springframework:
         security: ERROR
diff --git a/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java b/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java
index 7836edf94..4ea52570f 100644
--- a/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java
+++ b/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java
@@ -274,7 +274,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
 
     public void logout() {
         // POSTするリクエストパラメーターを作成
-        Logging.LogAction("refresh token ", this.oauth2ClientContext.getAccessToken().getRefreshToken().getValue());
         RestTemplate restTemplate = new RestTemplate();
         MultiValueMap<String, String> formParams = new LinkedMultiValueMap<>();
         formParams.add("client_id", hbp().getClientId());
@@ -284,7 +283,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
         HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
         // リクエストを作成
-        Logging.LogAction("logoutUri is ", logoutUri);
         RequestEntity<MultiValueMap<String, String>> requestEntity =
                 new RequestEntity<>(formParams, httpHeaders, HttpMethod.POST,
                         URI.create(logoutUri));
diff --git a/src/main/java/eu/hbp/mip/utils/Logging.java b/src/main/java/eu/hbp/mip/utils/Logging.java
index f3ed45e83..9b75de636 100644
--- a/src/main/java/eu/hbp/mip/utils/Logging.java
+++ b/src/main/java/eu/hbp/mip/utils/Logging.java
@@ -11,9 +11,7 @@ public class Logging {
 
     public static void LogUserAction(String userName, String endpoint, String actionInfo) {
         LOGGER.info(" User -> " + userName + " ,"
-                + calculateAdditionalSpacing(userName.length(), 8)
                 + "Endpoint -> " + endpoint + " ,"
-                + calculateAdditionalSpacing(endpoint.length(), 32)
                 + "Info ->  " + actionInfo);
     }
 
@@ -21,20 +19,6 @@ public class Logging {
     public static void LogExperimentAction(String experimentName, UUID experimentId, String actionInfo) {
         LOGGER.info(" Experiment -> " + experimentName
                 + "(" + experimentId + ") ,"
-                + calculateAdditionalSpacing(experimentName.length() + experimentId.toString().length() + 2, 20)
                 + "Info -> " + actionInfo);
     }
-
-    // Used when a user is not authorised yet
-    public static void LogAction(String actionName, String actionIdInfo) {
-        LOGGER.info(" Action -> " + actionName + " ,"
-                + calculateAdditionalSpacing(actionName.length() + 2, 20)
-                + "Info -> " + actionIdInfo);
-    }
-
-    // Calculates the spacing that is needed to create consistent logs.
-    private static String calculateAdditionalSpacing(Integer currentLen, Integer maxLen) {
-        int additionalSpacing = (maxLen > currentLen ? maxLen - currentLen + 2 : 2);
-        return String.format("%" + additionalSpacing + "s", "");
-    }
 }
-- 
GitLab


From ccbbcf37c0c6be785b1e7c0f6d90c9788a0aebc4 Mon Sep 17 00:00:00 2001
From: ThanKarab <tkarabatsis@hotmail.com>
Date: Fri, 23 Oct 2020 14:15:59 +0300
Subject: [PATCH 5/5] Log level default values and env variables changed.

---
 docker/README.md               |  4 ++--
 docker/config/application.tmpl | 10 ++--------
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/docker/README.md b/docker/README.md
index faedc351e..3f3437aec 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -46,8 +46,8 @@ To use this image, you need a running instance of PostgreSQL and to configure th
 
 ### LOGGING
 
-* LOGGING_LEVEL_WEB: log level for the web layer of the application. Default to "WARN".
-* LOGGING_LEVEL_HIBERNATE: log level for the Hibernate layer of the application. Default to "WARN".
+* LOG_LEVEL: log level for the developer added logs. Default is "ERROR".
+* LOG_LEVEL_FRAMEWORK: log level for all the framework logs. Default is "ERROR".
 
 
 ### ENDPOINTS
diff --git a/docker/config/application.tmpl b/docker/config/application.tmpl
index 8d76148db..13fc65779 100644
--- a/docker/config/application.tmpl
+++ b/docker/config/application.tmpl
@@ -50,15 +50,9 @@ frontend:
   
 logging:
   level:
-    root: {{ default .Env.LOG_LEVEL "ERROR" }}
-    org:
-      springframework:
-        security: ERROR
-        web: {{ default .Env.LOGGING_LEVEL_WEB "ERROR" }}
-        web.servlet.handler.BeanNameUrlHandlerMapping: ERROR
-      hibernate: {{ default .Env.LOGGING_LEVEL_HIBERNATE "ERROR" }}
+    root: {{ default .Env.LOG_LEVEL_FRAMEWORK "ERROR" }}
     eu:
-      hbp: {{ default .Env.LOGGING_LEVEL_MIP "INFO" }}
+      hbp: {{ default .Env.LOG_LEVEL "INFO" }}
 
 # EMBEDDED SERVER CONFIGURATION
 server:
-- 
GitLab