Skip to content
Snippets Groups Projects
Unverified Commit 04c18a45 authored by K.Filippopolitis's avatar K.Filippopolitis Committed by GitHub
Browse files

Redirect logs outside of console (#78)

* Redirect logs outside of console

* Log user log in and authorities.
parent 3e1bfd7c
No related branches found
Tags 8.0.5
No related merge requests found
......@@ -15,6 +15,8 @@ logging:
root: {{ default .Env.LOG_LEVEL_FRAMEWORK "ERROR" }}
eu:
hbp: {{ default .Env.LOG_LEVEL "INFO" }}
file:
name: /var/log/portalbackend/portalbackend.log
### DATABASE CONFIGURATION ###
......
package hbp.mip.configurations;
import hbp.mip.utils.Logger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class AuthenticationEventListener {
@EventListener
public void handleAuthenticationSuccess(AuthenticationSuccessEvent event) {
Authentication authentication = event.getAuthentication();
String username = authentication.getName();
Logger logger = new Logger(username, "LOGGING IN");
logger.info("User " + username + " has logged in successfully");
// If you need to log additional details:
authentication.getAuthorities().forEach(authority ->
logger.info("User " + username + " has authority " + authority.getAuthority())
);
}
}
# Configuration for development purposes
### EMBEDDED SERVER CONFIGURATION ###
server:
servlet:
......@@ -8,14 +7,14 @@ server:
port: 8080
forward-headers-strategy: native
### LOG LEVELS ###
logging:
level:
root: "INFO"
eu:
hbp: "DEBUG"
file:
name: /var/log/portalbackend/portalbackend.log
### DATABASE CONFIGURATION ###
spring:
......@@ -51,7 +50,6 @@ spring:
user-name-attribute: preferred_username
issuer-uri: http://172.17.0.1/auth/realms/MIP
### AUTHENTICATION ###
authentication:
enabled: 0
......@@ -59,7 +57,6 @@ authentication:
all_experiments_allowed_claim: research_experiment_all
dataset_claim_prefix: research_dataset_
### EXTERNAL SERVICES ###
services:
algorithmsUpdateInterval: 100
......@@ -68,7 +65,6 @@ services:
attributesUrl: "http://127.0.0.1:5000/data_models_attributes"
cdesMetadataUrl: "http://127.0.0.1:5000/cdes_metadata"
### EXTERNAL FILES ###
# Files are loaded from the resources
files:
......
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