거래파일로그(SIFT_LOGGER) 출력기능 개발
- UUID별로 거래파일로그 생성
This commit is contained in:
@@ -908,6 +908,41 @@ public class Logger implements LogKeys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// * 거래 파일 로그 추가 코드
|
||||||
|
// MDC txId가 있을 때만 SiftingAppender로 기록하는 필터
|
||||||
|
// (txId 없는 일반 로그가 default.log로 쌓이는 것 방지)
|
||||||
|
ch.qos.logback.core.filter.Filter<ILoggingEvent> txIdFilter = new ch.qos.logback.core.filter.AbstractMatcherFilter<ILoggingEvent>() {
|
||||||
|
@Override
|
||||||
|
public ch.qos.logback.core.spi.FilterReply decide(ILoggingEvent event) {
|
||||||
|
String txId = event.getMDCPropertyMap().get(DISCRIMINATOR);
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(txId) && !"default".equals(txId)) {
|
||||||
|
return ch.qos.logback.core.spi.FilterReply.ACCEPT;
|
||||||
|
}
|
||||||
|
return ch.qos.logback.core.spi.FilterReply.DENY;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
txIdFilter.start();
|
||||||
|
siftAppender.addFilter(txIdFilter);
|
||||||
|
|
||||||
|
// SIFT appender를 추가할 대상 로거 목록
|
||||||
|
// → ESBFW, ADAPTER, DEFAULT 등 거래 처리에 관여하는 로거 추가
|
||||||
|
String[] siftTargetLoggers = { LOGGER_ESBFW, LOGGER_ADAPTER, LOGGER_DEFAULT
|
||||||
|
// 필요 시 LOGGER_TRAN, LOGGER_NET 등 추가
|
||||||
|
};
|
||||||
|
|
||||||
|
for (String targetLoggerName : siftTargetLoggers) {
|
||||||
|
ch.qos.logback.classic.Logger targetLogger = (ch.qos.logback.classic.Logger) LoggerFactory
|
||||||
|
.getLogger(targetLoggerName);
|
||||||
|
|
||||||
|
if (targetLogger == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// siftAppender 추가 (기존 appender는 그대로 유지 - additive 건드리지 않음)
|
||||||
|
targetLogger.addAppender(siftAppender);
|
||||||
|
System.out.println("@ add SiftAppender to " + targetLogger.getName() + " - " + siftAppender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
System.err.println("@@ Logger Configure Error.===================");
|
System.err.println("@@ Logger Configure Error.===================");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -939,7 +974,7 @@ public class Logger implements LogKeys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
asisLevel = logger.getLevel();
|
asisLevel = logger.getLevel();
|
||||||
if ( asisLevel.toInt() != toLevel.toInt() ) {
|
if ( toLevel == null || asisLevel.toInt() != toLevel.toInt() ) {
|
||||||
logger.setLevel( toLevel );
|
logger.setLevel( toLevel );
|
||||||
System.out.println("@@ Logger setLoggerLevel | " + loggerName
|
System.out.println("@@ Logger setLoggerLevel | " + loggerName
|
||||||
+ " AS-IS [" + asisLevel.toString() + "] TO [" + toLevel.toString() + "]");
|
+ " AS-IS [" + asisLevel.toString() + "] TO [" + toLevel.toString() + "]");
|
||||||
|
|||||||
Reference in New Issue
Block a user