org.slf4j.Logger
및 자체 LogUtil
클래스 를 사용하는 새 Logger 클래스를 코딩하려고합니다 .
그래서 여기 내 문제가 있습니다. getInstance()
클래스의 변수로 초기화 될라 는 정적 메서드를 만들려고합니다 Vlogger
. 그러나 메서드의 반환 유형은 Logger
.
public class VLogger {
private static LogMessageBuilder logMessageBuilder;
private LogUtil logUtil;
public static Logger getInstance() {
// String className = new Exception().getStackTrace()[1].getClassName();
return LoggerFactory.getLogger(Reflection.getCallerClass().toString());
}}
여기에서 내가 원하는 이전 통화와 새 통화를 볼 수 있습니다.
Vlogger vlog = VLogger.getInstance();
대 :
private static Logger LOG =
LoggerFactory.getLogger(ResourceStatements.class);
나는 anwser를 얻었다 :
public static VLogger getInstance() {
VLogger result = new VLogger();
result.l = LoggerFactory.getLogger(new Exception().getStackTrace()[1].getClassName());
return result;
}
그리고 전화 :
vLogger.message("Folgende Statements wurden verwednet").att(test, m).debug();
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다