mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-02 19:27:57 +08:00
PL-6083 Add application name to logs
#PL-6083
This commit is contained in:
parent
3d581cfac9
commit
e365670bbc
@ -18,7 +18,8 @@ import org.springframework.context.ApplicationContext;
|
||||
*/
|
||||
public class LogMdc {
|
||||
|
||||
public static final String USER = "user";
|
||||
public static final String USER = "cubaUser";
|
||||
public static final String APPLICATION = "cubaApp";
|
||||
|
||||
public static void setup(SecurityContext securityContext) {
|
||||
String userProp = AppContext.getProperty("cuba.logUserName");
|
||||
@ -47,5 +48,14 @@ public class LogMdc {
|
||||
MDC.remove(USER);
|
||||
}
|
||||
}
|
||||
|
||||
String applicationProp = AppContext.getProperty("cuba.logAppName");
|
||||
if (applicationProp == null || Boolean.valueOf(applicationProp)) {
|
||||
if (securityContext != null) {
|
||||
MDC.put(APPLICATION, "/" + AppContext.getProperty("cuba.webContextName"));
|
||||
} else {
|
||||
MDC.remove(APPLICATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ public class LocalServiceProxy extends RemoteAccessor implements FactoryBean<Obj
|
||||
method.getName(), parameterTypeNames, argumentsData, notSerializableArguments, sessionId);
|
||||
|
||||
LocalServiceInvocationResult result = invoker.invoke(invocation);
|
||||
AppContext.setSecurityContext(AppContext.getSecurityContext());//need reset application name in LogMDC for the current thread
|
||||
|
||||
// don't use SerializationUtils.deserialize() here to avoid ClassNotFoundException
|
||||
if (result.getException() != null) {
|
||||
|
@ -121,6 +121,7 @@ public class LocalServiceProxy extends RemoteAccessor implements FactoryBean<Obj
|
||||
method.getName(), parameterTypeNames, argumentsData, notSerializableArguments, sessionId);
|
||||
|
||||
LocalServiceInvocationResult result = invoker.invoke(invocation);
|
||||
AppContext.setSecurityContext(AppContext.getSecurityContext());//need reset application name in LogMDC for the current thread
|
||||
|
||||
// don't use SerializationUtils.deserialize() here to avoid ClassNotFoundException
|
||||
if (result.getException() != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user