Java Code Examples for org.apache.log4j.Level#toString()

The following examples show how to use org.apache.log4j.Level#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteSystemOperations.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void setAtsDbAppenderThreshold( Level threshold ) {

    try {
        this.remoteSystemOperations.setAtsDbAppenderThreshold(threshold);
    } catch (AgentException e) {
        throw new SystemOperationException("Could not set ATS DB Appender threshold to " + threshold.toString()
                                           + " on agent: " + atsAgent, e);
    }

}
 
Example 2
Source File: LoggerDynamicMBean.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public
 Object getAttribute(String attributeName) throws AttributeNotFoundException,
                                                  MBeanException,
                                                  ReflectionException {

      // Check attributeName is not null to avoid NullPointerException later on
   if (attributeName == null) {
     throw new RuntimeOperationsException(new IllegalArgumentException(
		"Attribute name cannot be null"),
      "Cannot invoke a getter of " + dClassName + " with null attribute name");
   }

   // Check for a recognized attributeName and call the corresponding getter
   if (attributeName.equals("name")) {
     return logger.getName();
   }  else if(attributeName.equals("priority")) {
     Level l = logger.getLevel();
     if(l == null) {
return null;
     } else {
return l.toString();
     }
   } else if(attributeName.startsWith("appender=")) {
     try {
return new ObjectName("log4j:"+attributeName );
     } catch(Exception e) {
cat.error("Could not create ObjectName" + attributeName);
     }
   }


   // If attributeName has not been recognized throw an AttributeNotFoundException
   throw(new AttributeNotFoundException("Cannot find " + attributeName +
				 " attribute in " + dClassName));

 }
 
Example 3
Source File: PropertyPrinter.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected
void printOptions(PrintWriter out, Category cat) {
  Enumeration appenders = cat.getAllAppenders();
  Level prio = cat.getLevel();
  String appenderString = (prio == null ? "" : prio.toString());
  
  while (appenders.hasMoreElements()) {
    Appender app = (Appender) appenders.nextElement();
    String name;
    
    if ((name = (String) appenderNames.get(app)) == null) {
    
      // first assign name to the appender
      if ((name = app.getName()) == null || isGenAppName(name)) {
          name = genAppName();
      }
      appenderNames.put(app, name);
      
      printOptions(out, app, "log4j.appender."+name);
      if (app.getLayout() != null) {
        printOptions(out, app.getLayout(), "log4j.appender."+name+".layout");
      }
    }
    appenderString += ", " + name;
  }
  String catKey = (cat == Logger.getRootLogger())
      ? "log4j.rootLogger"
      : "log4j.logger." + cat.getName();
  if (appenderString != "") {
    out.println(catKey + "=" + appenderString);
  }
  if (!cat.getAdditivity() && cat != Logger.getRootLogger()) {
  	out.println("log4j.additivity." + cat.getName() + "=false");    
  }
}
 
Example 4
Source File: LoggerSerializer.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
private String getLoggerLevel(Category logger) {
  if (null == logger) {
    return StringUtils.EMPTY;
  }
  Level level = logger.getLevel();
  if (null != level) {
    return level.toString();
  } else {
    return getLoggerLevel(logger.getParent());
  }
}
 
Example 5
Source File: TajoLogEventCounter.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Override
public void append(LoggingEvent event) {
  Level level = event.getLevel();
  String levelStr = level.toString();

  if (level == Level.INFO || "INFO".equalsIgnoreCase(levelStr)) {
    counts.incr(INFO);
  } else if (level == Level.WARN || "WARN".equalsIgnoreCase(levelStr)) {
    counts.incr(WARN);
  } else if (level == Level.ERROR || "ERROR".equalsIgnoreCase(levelStr)) {
    counts.incr(ERROR);
  } else if (level == Level.FATAL || "FATAL".equalsIgnoreCase(levelStr)) {
    counts.incr(FATAL);
  }
}
 
Example 6
Source File: TajoLogEventCounter.java    From incubator-tajo with Apache License 2.0 5 votes vote down vote up
@Override
public void append(LoggingEvent event) {
  Level level = event.getLevel();
  String levelStr = level.toString();

  if (level == Level.INFO || "INFO".equalsIgnoreCase(levelStr)) {
    counts.incr(INFO);
  } else if (level == Level.WARN || "WARN".equalsIgnoreCase(levelStr)) {
    counts.incr(WARN);
  } else if (level == Level.ERROR || "ERROR".equalsIgnoreCase(levelStr)) {
    counts.incr(ERROR);
  } else if (level == Level.FATAL || "FATAL".equalsIgnoreCase(levelStr)) {
    counts.incr(FATAL);
  }
}
 
Example 7
Source File: LoggerConfigurator.java    From maven-framework-project with MIT License 5 votes vote down vote up
@ManagedOperation(description = "Returns the Logger LEVEL for the given logger name")
@ManagedOperationParameters({ @ManagedOperationParameter(description = "The Logger Name", name = "loggerName"), })
public String getLoggerLevel(String loggerName) {

	Logger logger = Logger.getLogger(loggerName);
	Level loggerLevel = logger.getLevel();

	return loggerLevel == null ? "The logger " + loggerName
			+ " has not level" : loggerLevel.toString();

}
 
Example 8
Source File: LogManager.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public String getLoggerLevel(String loggerName) {

    Logger logger = Logger.getLogger(loggerName);
    if (logger == null) {
        throw new IllegalArgumentException("Logger \"" + loggerName +
                "\" does not exist");
    }
    Level level = logger.getEffectiveLevel();
    if (level == null) {
        return "";
    }
    return level.toString();
}
 
Example 9
Source File: LoggerUtil.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Override
public String apply(@Nullable Level input)
{
  return input == null ? "" : input.toString();
}
 
Example 10
Source File: LoggerUtil.java    From attic-apex-core with Apache License 2.0 4 votes vote down vote up
@Override
public String apply(@Nullable Level input)
{
  return input == null ? "" : input.toString();
}
 
Example 11
Source File: LogOperation.java    From hazelcast-simulator with Apache License 2.0 4 votes vote down vote up
public LogOperation(String message, Level level) {
    this.message = message;
    this.level = level.toString();
}