diff --git a/Dockerfile b/Dockerfile index a4fa1142fec4c0bdcf6db4e9ff8a475784daa6be..458fbc8a353233f0bda3dbff9be8b421d7fbaf5b 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/ diff --git a/docker/README.md b/docker/README.md index faedc351ea8e722aa98e0693f7d7fad119c84325..3f3437aec65ab4cc28b6236bf31a305b79572ea5 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 6174fb409d967a2c67b5013ecc435a72fd763929..13fc6577970ede925089895265e8a3f6b0a409ae 100644 --- a/docker/config/application.tmpl +++ b/docker/config/application.tmpl @@ -50,15 +50,9 @@ frontend: logging: level: - root: {{ default .Env.LOG_LEVEL "INFO" }} - org: - springframework: - security: DEBUG - web: {{ default .Env.LOGGING_LEVEL_WEB "WARN" }} - web.servlet.handler.BeanNameUrlHandlerMapping: WARN - hibernate: {{ default .Env.LOGGING_LEVEL_HIBERNATE "WARN" }} + 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: diff --git a/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java b/src/main/java/eu/hbp/mip/configuration/SecurityConfiguration.java index 7836edf941914247a7a86d41d63108bfb33d3316..4ea52570fd3bde8c8b21253fe202aa3fc61363d4 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 f3ed45e83315c66b6a1714b0096dd183af13ab5e..9b75de636fc7c1721fca6dba59e2ce38cced1a7d 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", ""); - } } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml deleted file mode 100644 index 0726d82f41564d850f92eaa301010d39ea89b068..0000000000000000000000000000000000000000 --- 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