You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

26 lines
775 B

package ru.digitalbanana.demoresourceserver.config;
import org.slf4j.*;
import org.springframework.beans.factory.InjectionPoint;
import org.springframework.context.annotation.*;
import org.springframework.core.MethodParameter;
import static java.util.Optional.*;
import java.lang.reflect.Field;
@Configuration
public class LoggingConfiguration {
@Bean
@Scope("prototype")
public Logger logger(final InjectionPoint ip) {
return LoggerFactory.getLogger(of(ip.getMethodParameter())
.<Class>map(MethodParameter::getContainingClass)
.orElseGet(
() -> ofNullable(ip.getField())
.map(Field::getDeclaringClass)
.orElseThrow(IllegalArgumentException::new)
)
);
}
}