本文整理汇总了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);
}
}