本文整理匯總了Java中ch.qos.logback.classic.Logger.iteratorForAppenders方法的典型用法代碼示例。如果您正苦於以下問題:Java Logger.iteratorForAppenders方法的具體用法?Java Logger.iteratorForAppenders怎麽用?Java Logger.iteratorForAppenders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ch.qos.logback.classic.Logger
的用法示例。
在下文中一共展示了Logger.iteratorForAppenders方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLogFromLogback
import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
private static Path getLogFromLogback( final File logbackConfig )
{
try
{
LoggerContext loggerContext = new LoggerContext();
JoranConfigurator jc = new JoranConfigurator();
jc.setContext( loggerContext );
loggerContext.reset();
jc.doConfigure( logbackConfig );
for ( Logger logger : loggerContext.getLoggerList() )
{
for ( Iterator<Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext(); )
{
Appender<ILoggingEvent> appender = index.next();
if ( appender instanceof FileAppender )
{
return Paths.get( ( (FileAppender) appender ).getFile() );
}
}
}
return null;
}
catch ( Exception e )
{
return null;
}
}
示例2: figureoutLogConfiguration
import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
private void figureoutLogConfiguration(Logger Logger, LinkedList<LogProfileInfo> list, String appid) {
Iterator<Appender<ILoggingEvent>> appenders = Logger.iteratorForAppenders();
while (appenders != null && appenders.hasNext()) {
LogProfileInfo logProfileInfo = new LogProfileInfo();
if (appid != null) {
logProfileInfo.setAppId(appid);
}
logProfileInfo.setLogType(LogProfileInfo.LogType.Log4j);
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(LogProfileInfo.ENGINE, "logback");
Appender<ILoggingEvent> appender = appenders.next();
if (!(appender instanceof FileAppender<?>)) {
continue;
}
FileAppender<ILoggingEvent> fileAppender = (FileAppender<ILoggingEvent>) appender;
@SuppressWarnings("rawtypes")
LayoutWrappingEncoder encoder = (LayoutWrappingEncoder) fileAppender.getEncoder();
Layout<?> layout = encoder.getLayout();
if (null != layout) {
if (layout instanceof PatternLayout) {
PatternLayout patternLayout = (PatternLayout) encoder.getLayout();
attributes.put(LogProfileInfo.PATTERN, patternLayout.getPattern());
}
else if (layout instanceof HTMLLayout) {
attributes.put(LogProfileInfo.PATTERN, "HTMLLayout");
}
else if (layout instanceof XMLLayout) {
attributes.put(LogProfileInfo.PATTERN, "XMLLayout");
}
else if (layout instanceof TTLLLayout) {
attributes.put(LogProfileInfo.PATTERN, "TTCCLayout");
}
}
logProfileInfo.setFilePath(fileAppender.getFile());
logProfileInfo.setAttributes(attributes);
list.add(logProfileInfo);
}
}