Java Code Examples for org.apache.log4j.Level#OFF

The following examples show how to use org.apache.log4j.Level#OFF . 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: IngestUtilities.java    From cognition with Apache License 2.0 6 votes vote down vote up
public static Level levelFromString(String level) {
  String ulevel = level.toUpperCase();
  if (ulevel.equals("ALL")) {
    return Level.ALL;
  } else if (ulevel.equals("DEBUG")) {
    return Level.DEBUG;
  } else if (ulevel.equals("ERROR")) {
    return Level.ERROR;
  } else if (ulevel.equals("FATAL")) {
    return Level.FATAL;
  } else if (ulevel.equals("INFO")) {
    return Level.INFO;
  } else if (ulevel.equals("OFF")) {
    return Level.OFF;
  } else if (ulevel.equals("TRACE")) {
    return Level.TRACE;
  } else if (ulevel.equals("WARN")) {
    return Level.WARN;
  }
  return Level.INFO;
}
 
Example 2
Source File: CentralLogStore.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private static Level convertKettleLogLevelToLog4jLevel( LogLevel level ) {
  switch ( level ) {
    case BASIC:
      return Level.INFO;
    case DETAILED:
      return Level.INFO;
    case DEBUG:
      return Level.DEBUG;
    case ROWLEVEL:
      return Level.DEBUG;
    case MINIMAL:
      return Level.INFO;
    case ERROR:
      return Level.ERROR;
    case NOTHING:
      return Level.OFF;
    default:
      return Level.INFO;
  }
}
 
Example 3
Source File: OptionConverter.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
public static Level convertLevel(org.apache.logging.log4j.Level level) {
    if (level == null) {
        return Level.ERROR;
    }
    switch (level.getStandardLevel()) {
        case FATAL:
            return Level.FATAL;
        case WARN:
            return Level.WARN;
        case INFO:
            return Level.INFO;
        case DEBUG:
            return Level.DEBUG;
        case TRACE:
            return Level.TRACE;
        case ALL:
            return Level.ALL;
        case OFF:
            return Level.OFF;
        default:
            return Level.ERROR;
    }
}
 
Example 4
Source File: LogEventAdapter.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
/**
 * Return the level of this event. Use this form instead of directly
 * accessing the <code>level</code> field.
 */
@Override
public Level getLevel() {
    switch (StandardLevel.getStandardLevel(event.getLevel().intLevel())) {
        case TRACE:
            return Level.TRACE;
        case DEBUG:
            return Level.DEBUG;
        case INFO:
            return Level.INFO;
        case WARN:
            return Level.WARN;
        case FATAL:
            return Level.FATAL;
        case OFF:
            return Level.OFF;
        case ALL:
            return Level.ALL;
        default:
            return Level.ERROR;
    }
}
 
Example 5
Source File: LogEventAdapter.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
/**
 * Return the level of this event. Use this form instead of directly
 * accessing the <code>level</code> field.  */
@Override
public Level getLevel() {
    switch (StandardLevel.getStandardLevel(event.getLevel().intLevel())) {
        case TRACE:
            return Level.TRACE;
        case DEBUG:
            return Level.DEBUG;
        case INFO:
            return Level.INFO;
        case WARN:
            return Level.WARN;
        case ERROR:
            return Level.ERROR;
        case FATAL:
            return Level.FATAL;
        case OFF:
            return Level.OFF;
        case ALL:
            return Level.ALL;
        default:
            return Level.ERROR;
    }
}
 
Example 6
Source File: TestUtils.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
static void addTestAppenderForRootLogger() {
	org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();

	// hide logging output unless explicitly enabled
	if (rootLogger.getLevel() == Level.OFF) {
		org.apache.log4j.Logger.getRootLogger().removeAllAppenders();
	}

	org.apache.log4j.Logger logger = org.apache.log4j.LogManager.getLogger(Slf4jReporter.class);
	logger.setLevel(org.apache.log4j.Level.INFO);

	testAppender = new TestAppender();
	logger.addAppender(testAppender);
}
 
Example 7
Source File: TestUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
static void addTestAppenderForRootLogger() {
	org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();

	// hide logging output unless explicitly enabled
	if (rootLogger.getLevel() == Level.OFF) {
		org.apache.log4j.Logger.getRootLogger().removeAllAppenders();
	}

	org.apache.log4j.Logger logger = org.apache.log4j.LogManager.getLogger(Slf4jReporter.class);
	logger.setLevel(org.apache.log4j.Level.INFO);

	testAppender = new TestAppender();
	logger.addAppender(testAppender);
}
 
Example 8
Source File: NOPLogger.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create instance of Logger.
 * @param repo repository, may not be null.
 * @param name name, may not be null, use "root" for root logger.
 */
public NOPLogger(NOPLoggerRepository repo, final String name) {
    super(name);
    this.repository = repo;
    this.level = Level.OFF;
    this.parent = this;
}
 
Example 9
Source File: Log4jMessageLogger.java    From knox with Apache License 2.0 5 votes vote down vote up
private static Level toLevel( final MessageLevel level ) {
  switch( level ) {
    case FATAL: return Level.FATAL;
    case ERROR: return Level.ERROR;
    case WARN: return Level.WARN;
    case INFO: return Level.INFO;
    case DEBUG: return Level.DEBUG;
    case TRACE: return Level.TRACE;
    default: return Level.OFF;
  }
}
 
Example 10
Source File: NOPLoggerRepository.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Level getThreshold() {
    return Level.OFF;
}
 
Example 11
Source File: NOPLogger.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/** {@inheritDoc} */
public Level getEffectiveLevel() {
  return Level.OFF;
}
 
Example 12
Source File: LogInitializer.java    From DataGenerator with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes log4j
 *
 * @param loggerLevel log level to initialize to
 */
public static void initialize(String loggerLevel) {
    if (!INIT.compareAndSet(false, true)) {
        return;
    }

    BasicConfigurator.resetConfiguration();
    ConsoleAppender consoleAppender = new ConsoleAppender(
        new PatternLayout("<%d{yyMMdd HHmmss} %5p %C{1}:%L> %m%n"), ConsoleAppender.SYSTEM_ERR);
    BasicConfigurator.configure(consoleAppender);

    Level level;

    String logLevel;

    if (loggerLevel != null) {
        logLevel = loggerLevel.toLowerCase();
    } else {
        logLevel = "default";
    }

    switch (logLevel) {
        case "all":
            level = Level.ALL;
            break;
        case "debug":
            level = Level.DEBUG;
            break;
        case "error":
            level = Level.ERROR;
            break;
        case "fatal":
            level = Level.FATAL;
            break;
        case "info":
            level = Level.INFO;
            break;
        case "off":
            level = Level.OFF;
            break;
        case "trace":
            level = Level.TRACE;
            break;
        case "warn":
            level = Level.WARN;
            break;
        default:
            level = Level.INFO;
            break;
    }

    Logger.getRootLogger().setLevel(Level.OFF);
    Logger.getLogger("org.finra").setLevel(level);

    System.err.println("Set loglevel to " + level.toString());
}
 
Example 13
Source File: AbstractCommand.java    From allure1 with Apache License 2.0 4 votes vote down vote up
/**
 * Get log level depends on provided client parameters such as verbose and quiet.
 */
private Level getLogLevel() {
    return isQuiet() ? Level.OFF : isVerbose() ? Level.DEBUG : Level.INFO;
}