本文整理汇总了Java中ch.qos.logback.classic.LoggerContext.getLoggerList方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerContext.getLoggerList方法的具体用法?Java LoggerContext.getLoggerList怎么用?Java LoggerContext.getLoggerList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.classic.LoggerContext
的用法示例。
在下文中一共展示了LoggerContext.getLoggerList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMetricsMarkerLogbackFilter
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
onMarkerMetricsEvaluator.setContext(context);
onMarkerMetricsEvaluator.addMarker("metrics");
onMarkerMetricsEvaluator.start();
EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
metricsFilter.setContext(context);
metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
metricsFilter.setOnMatch(FilterReply.DENY);
metricsFilter.start();
for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) {
Appender<ILoggingEvent> appender = it.next();
if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
log.debug("Filter metrics logs from the {} appender", appender.getName());
appender.setContext(context);
appender.addFilter(metricsFilter);
appender.start();
}
}
}
}
示例2: setMetricsMarkerLogbackFilter
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
onMarkerMetricsEvaluator.setContext(context);
onMarkerMetricsEvaluator.addMarker("metrics");
onMarkerMetricsEvaluator.start();
EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
metricsFilter.setContext(context);
metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
metricsFilter.setOnMatch(FilterReply.DENY);
metricsFilter.start();
for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext(); ) {
Appender<ILoggingEvent> appender = it.next();
if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
log.debug("Filter metrics logs from the {} appender", appender.getName());
appender.setContext(context);
appender.addFilter(metricsFilter);
appender.start();
}
}
}
}
示例3: getLogFromLogback
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的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;
}
}
示例4: figureOutLogBackConfig
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
/**
* figure out the logback's configuration: for example, appenders' file path, buff io, etc...
*
* @param context
* @param webapploader
*/
private void figureOutLogBackConfig(HookContext context, ClassLoader webapploader) {
Logger logback = (Logger) LoggerFactory.getLogger(LogBackHookProxy.class);
InterceptContext interceptContext = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT);
if (interceptContext == null) {
logback.warn("No InterceptContext available, can't figure out LogBack configuration.");
return;
}
@SuppressWarnings("unchecked")
LinkedList<LogProfileInfo> list = (LinkedList<LogProfileInfo>) interceptContext
.get(HookConstants.LOG_PROFILE_LIST);
if (null == list) {
list = new LinkedList<LogProfileInfo>();
interceptContext.put(HookConstants.LOG_PROFILE_LIST, list);
}
String appid = (String) (interceptContext.get(InterceptConstants.CONTEXTPATH));
// figureour all loggers
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
List<ch.qos.logback.classic.Logger> loggers = loggerContext.getLoggerList();
for (Logger logger : loggers) {
figureoutLogConfiguration(logger, list, appid);
}
}
示例5: initLogger
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
/**
* Initialize the logger, in order to display all the log messages in a text
* logger on the gui.
*/
private void initLogger() {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
// find the appender which is an instance of the text area appender and set the text area where it should put the text
for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
// iterate the appenders in order to find the wanted one
for (Iterator<Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext();) {
Appender<ILoggingEvent> appender = index.next();
// just the TextAreaAppender type is needed to be correctly initialised
if (appender instanceof TextAreaAppender) {
((TextAreaAppender) appender).setTextArea(jTALog, jTAShortLog);
}
}
}
}
示例6: LogWindow
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
/**
* Constructor
*/
public LogWindow(final Window parent) {
super(parent, "Log", ModalityType.DOCUMENT_MODAL);
final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
for (final ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
for (final Iterator<ch.qos.logback.core.Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext();) {
final ch.qos.logback.core.Appender<ILoggingEvent> appender = index.next();
if (appender instanceof Appender) {
_appender = (Appender) appender;
break;
}
}
}
_logs = new JTextPane() {
@Override
public boolean getScrollableTracksViewportWidth() {
return getUI().getPreferredSize(this).width <= getParent().getSize().width;
}
};
if (_appender != null) {
_appender.display = this;
}
try {
for (final String line : Util.readUTF8File(new FileInputStream(Env.LOG_FILE))) {
appendFormatted(line + "\n");
}
} catch (final FileNotFoundException e1) {
appendFormatted("Failed to open file " + Env.LOG_FILE.getAbsolutePath());
}
final JScrollPane scroll = new JScrollPane(_logs, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setPreferredSize(new Dimension(800, 600));
getContentPane().add(scroll, BorderLayout.CENTER);
final JButton close = new JButton(Resources.getLabel("close.button"));
close.addActionListener(e -> LogWindow.this.dispose());
getContentPane().add(close, BorderLayout.SOUTH);
SwingUtilities4.setUp(this);
getRootPane().registerKeyboardAction(e -> {
_appender.display = null;
dispose();
if (parent != null) {
parent.toFront();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
}