Skip to content
Snippets Groups Projects
Unverified Commit a3ec6057 authored by ThanKarab's avatar ThanKarab Committed by GitHub
Browse files

Merge pull request #17 from HBPMedical/feat/elk_stack

Feat/elk stack
parents 8b7fe960 ccbbcf37
No related branches found
No related tags found
No related merge requests found
...@@ -14,8 +14,7 @@ RUN cp /usr/share/maven/ref/settings-docker.xml /root/.m2/settings.xml \ ...@@ -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 FROM hbpmip/java-base:11.0.1-1
RUN apt-get update && apt-get install -y --no-install-recommends curl \ RUN rm -rf /var/lib/apt/lists/* /tmp/*
&& rm -rf /var/lib/apt/lists/* /tmp/*
COPY docker/config/application.tmpl /opt/portal/config/application.tmpl COPY docker/config/application.tmpl /opt/portal/config/application.tmpl
COPY docker/README.md docker/run.sh /opt/portal/ COPY docker/README.md docker/run.sh /opt/portal/
......
...@@ -46,8 +46,8 @@ To use this image, you need a running instance of PostgreSQL and to configure th ...@@ -46,8 +46,8 @@ To use this image, you need a running instance of PostgreSQL and to configure th
### LOGGING ### LOGGING
* LOGGING_LEVEL_WEB: log level for the web layer of the application. Default to "WARN". * LOG_LEVEL: log level for the developer added logs. Default is "ERROR".
* LOGGING_LEVEL_HIBERNATE: log level for the Hibernate layer of the application. Default to "WARN". * LOG_LEVEL_FRAMEWORK: log level for all the framework logs. Default is "ERROR".
### ENDPOINTS ### ENDPOINTS
......
...@@ -50,15 +50,9 @@ frontend: ...@@ -50,15 +50,9 @@ frontend:
logging: logging:
level: level:
root: {{ default .Env.LOG_LEVEL "INFO" }} root: {{ default .Env.LOG_LEVEL_FRAMEWORK "ERROR" }}
org:
springframework:
security: DEBUG
web: {{ default .Env.LOGGING_LEVEL_WEB "WARN" }}
web.servlet.handler.BeanNameUrlHandlerMapping: WARN
hibernate: {{ default .Env.LOGGING_LEVEL_HIBERNATE "WARN" }}
eu: eu:
hbp: {{ default .Env.LOGGING_LEVEL_MIP "INFO" }} hbp: {{ default .Env.LOG_LEVEL "INFO" }}
# EMBEDDED SERVER CONFIGURATION # EMBEDDED SERVER CONFIGURATION
server: server:
......
...@@ -274,7 +274,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { ...@@ -274,7 +274,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
public void logout() { public void logout() {
// POSTするリクエストパラメーターを作成 // POSTするリクエストパラメーターを作成
Logging.LogAction("refresh token ", this.oauth2ClientContext.getAccessToken().getRefreshToken().getValue());
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, String> formParams = new LinkedMultiValueMap<>(); MultiValueMap<String, String> formParams = new LinkedMultiValueMap<>();
formParams.add("client_id", hbp().getClientId()); formParams.add("client_id", hbp().getClientId());
...@@ -284,7 +283,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { ...@@ -284,7 +283,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
HttpHeaders httpHeaders = new HttpHeaders(); HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
// リクエストを作成 // リクエストを作成
Logging.LogAction("logoutUri is ", logoutUri);
RequestEntity<MultiValueMap<String, String>> requestEntity = RequestEntity<MultiValueMap<String, String>> requestEntity =
new RequestEntity<>(formParams, httpHeaders, HttpMethod.POST, new RequestEntity<>(formParams, httpHeaders, HttpMethod.POST,
URI.create(logoutUri)); URI.create(logoutUri));
......
...@@ -11,9 +11,7 @@ public class Logging { ...@@ -11,9 +11,7 @@ public class Logging {
public static void LogUserAction(String userName, String endpoint, String actionInfo) { public static void LogUserAction(String userName, String endpoint, String actionInfo) {
LOGGER.info(" User -> " + userName + " ," LOGGER.info(" User -> " + userName + " ,"
+ calculateAdditionalSpacing(userName.length(), 8)
+ "Endpoint -> " + endpoint + " ," + "Endpoint -> " + endpoint + " ,"
+ calculateAdditionalSpacing(endpoint.length(), 32)
+ "Info -> " + actionInfo); + "Info -> " + actionInfo);
} }
...@@ -21,20 +19,6 @@ public class Logging { ...@@ -21,20 +19,6 @@ public class Logging {
public static void LogExperimentAction(String experimentName, UUID experimentId, String actionInfo) { public static void LogExperimentAction(String experimentName, UUID experimentId, String actionInfo) {
LOGGER.info(" Experiment -> " + experimentName LOGGER.info(" Experiment -> " + experimentName
+ "(" + experimentId + ") ," + "(" + experimentId + ") ,"
+ calculateAdditionalSpacing(experimentName.length() + experimentId.toString().length() + 2, 20)
+ "Info -> " + actionInfo); + "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", "");
}
} }
<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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment