org.apache.log4j.Appender.getName()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.apache.log4j.Appender.getName()方法的一些代码示例,展示了Appender.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Appender.getName()方法的具体详情如下:
包路径:org.apache.log4j.Appender
类名称:Appender
方法名:getName

Appender.getName介绍

[英]Get the name of this appender. The name uniquely identifies the appender.
[中]获取此追加器的名称。该名称唯一标识追加器。

代码示例

代码示例来源:origin: log4j/log4j

void  registryPut(Appender appender) {
 registry.put(appender.getName(), appender);
}

代码示例来源:origin: log4j/log4j

/**
  * Get MBean name.
  * @param appender appender, may not be null.
  * @return name.
  * @since 1.2.16
  */
static protected String getAppenderName(final Appender appender){
  String name = appender.getName();
  if (name == null || name.trim().length() == 0) {
    // try to get some form of a name, because null is not allowed (exception), and empty string certainly isn't useful in JMX..
    name = appender.toString();
  }
  return name;
}

代码示例来源:origin: log4j/log4j

/**
 Remove the appender with the name passed as parameter form the
 list of appenders.  
*/
public
void removeAppender(String name) {
 if(name == null || appenderList == null) return;
 int size = appenderList.size();
 for(int i = 0; i < size; i++) {
  if(name.equals(((Appender)appenderList.elementAt(i)).getName())) {
  appenderList.removeElementAt(i);
  break;
  }
 }
}

代码示例来源:origin: log4j/log4j

/**
  Look for an attached appender named as <code>name</code>.
  <p>Return the appender with that name if in the list. Return null
  otherwise.  
  
 */
public
Appender getAppender(String name) {
  if(appenderList == null || name == null)
  return null;
  int size = appenderList.size();
  Appender appender;
  for(int i = 0; i < size; i++) {
   appender = (Appender) appenderList.elementAt(i);
   if(name.equals(appender.getName()))
  return appender;
  }
  return null;    
}

代码示例来源:origin: log4j/log4j

public
void removeAppenderEvent(Category cat, Appender appender) {
 log.debug("removeAppenderCalled: logger="+cat.getName()+
    ", appender="+appender.getName());
}

代码示例来源:origin: log4j/log4j

/**
  Set the backup appender.
 */
public
void setBackupAppender(Appender backup) {
 LogLog.debug("FB: Setting backup appender to [" + backup.getName() + "].");
 this.backup = backup;
}

代码示例来源:origin: log4j/log4j

/**
  The appender to which this error handler is attached.
 */
public
void setAppender(Appender primary) {
 LogLog.debug("FB: Setting primary appender to [" + primary.getName() + "].");
 this.primary = primary;
}

代码示例来源:origin: log4j/log4j

if(attributeName.startsWith("appender="+appender.getName()+",layout")) {
 try {
  return new ObjectName("log4j:"+attributeName );

代码示例来源:origin: log4j/log4j

/**
  Prints the message and the stack trace of the exception on
  <code>System.err</code>.
 */
public
void error(String message, Exception e, int errorCode, LoggingEvent event) {
 if (e instanceof InterruptedIOException) {
   Thread.currentThread().interrupt();
 }
 LogLog.debug("FB: The following error reported: " + message, e);
 LogLog.debug("FB: INITIATING FALLBACK PROCEDURE.");
 if (loggers != null) {
   for(int i = 0; i < loggers.size(); i++) {
      Logger l = (Logger) loggers.elementAt(i);
      LogLog.debug("FB: Searching for ["+primary.getName()+"] in logger ["
         +l.getName() + "].");
      LogLog.debug("FB: Replacing ["+primary.getName()+"] by ["
         + backup.getName() + "] in logger ["+ l.getName() +"].");
      l.removeAppender(primary);
      LogLog.debug("FB: Adding appender ["+backup.getName()+"] to logger "
         +  l.getName());
      l.addAppender(backup);
   }
 }    
}

代码示例来源:origin: pentaho/pentaho-kettle

public boolean close() {
 boolean isNotEmbedded = true;
 try {
  // Close all appenders only if we are not embedded (ie. running a report in BA Server
  // that has a PDI data source is considered embedded)
  Logger logger = Logger.getLogger( STRING_PENTAHO_DI_LOGGER_NAME );
  Enumeration<?> appenders = logger.getAllAppenders();
  while ( appenders.hasMoreElements() ) {
   final Appender appender = (Appender) appenders.nextElement();
   // Check to see if we have registered BA Server appenders
   if ( ( appender.getName().compareTo( STRING_PENTAHO_BASERVER_FILE_APPENDER ) == 0 )
    || ( appender.getName().compareTo( STRING_PENTAHO_BASERVER_CONSOLE_APPENDER ) == 0 ) ) {
    isNotEmbedded = false;
    break;
   }
  }
  // If we are not embedded, we can safely close all appenders.
  if ( isNotEmbedded == true ) {
   pentahoLogger.removeAllAppenders();
   LogWriter.unsetLogWriter();
  }
 } catch ( Exception e ) {
  isNotEmbedded = false;
 }
 return isNotEmbedded;
}

代码示例来源:origin: log4j/log4j

+"] to appender named ["+appender.getName()+"].");
appender.addFilter(filter);

代码示例来源:origin: log4j/log4j

+"] to appender named ["+appender.getName()+"].");
appender.addFilter(filter);

代码示例来源:origin: log4j/log4j

AppenderAttachable aa = (AppenderAttachable) appender;
 LogLog.debug("Attaching appender named ["+ refName+
    "] to appender named ["+ appender.getName()+"].");
 aa.addAppender(findAppenderByReference(currentElement));
} else {
 LogLog.error("Requesting attachment of appender named ["+
    refName+ "] to appender named ["+ appender.getName()+
    "] which does not implement org.apache.log4j.spi.AppenderAttachable.");

代码示例来源:origin: log4j/log4j

if ((name = app.getName()) == null || isGenAppName(name)) {
  name = genAppName();

代码示例来源:origin: apache/ignite

if ("CONSOLE_ERR".equals(appender.getName())) {

代码示例来源:origin: apache/ignite

if ("CONSOLE_ERR".equals(appender.getName())) {

代码示例来源:origin: camunda/camunda-bpm-platform

/**
  The appender to which this error handler is attached.
 */
public
void setAppender(Appender primary) {
 LogLog.debug("FB: Setting primary appender to [" + primary.getName() + "].");
 this.primary = primary;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
  Set the backup appender.
 */
public
void setBackupAppender(Appender backup) {
 LogLog.debug("FB: Setting backup appender to [" + backup.getName() + "].");
 this.backup = backup;
}

代码示例来源:origin: apache/log4j

/**
  Set the backup appender.
 */
public
void setBackupAppender(Appender backup) {
 LogLog.debug("FB: Setting backup appender to [" + backup.getName() + "].");
 this.backup = backup;
}

代码示例来源:origin: apache/log4j

public
void addAppenderEvent(Category logger, Appender appender) {
 log.debug("addAppenderEvent called: logger="+logger.getName()+
    ", appender="+appender.getName());
 Notification n = new Notification(ADD_APPENDER+logger.getName(), this, 0);
 n.setUserData(appender);
 log.debug("sending notification.");
 nbs.sendNotification(n);
}

相关文章