Java Code Examples for ch.qos.logback.classic.Level#OFF

The following examples show how to use ch.qos.logback.classic.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: SelfCheckHttpServer.java    From krpc with Apache License 2.0 6 votes vote down vote up
public Level toLevel(String sArg) {
    if (sArg == null) {
        return null;
    } else if (sArg.equalsIgnoreCase("ALL")) {
        return Level.ALL;
    } else if (sArg.equalsIgnoreCase("TRACE")) {
        return Level.TRACE;
    } else if (sArg.equalsIgnoreCase("DEBUG")) {
        return Level.DEBUG;
    } else if (sArg.equalsIgnoreCase("INFO")) {
        return Level.INFO;
    } else if (sArg.equalsIgnoreCase("WARN")) {
        return Level.WARN;
    } else if (sArg.equalsIgnoreCase("ERROR")) {
        return Level.ERROR;
    } else {
        return sArg.equalsIgnoreCase("OFF") ? Level.OFF : null;
    }
}
 
Example 2
Source File: LoggerNameAndLevelFilterTest.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
@Test
public void testDecideForTurnedOffLogger() throws Exception
{
    LoggerNameAndLevelFilter filter = new LoggerNameAndLevelFilter("org.apache.qpid", Level.OFF);

    ILoggingEvent event = mock(ILoggingEvent.class);
    when(event.getLevel()).thenReturn(Level.WARN);
    when(event.getLoggerName()).thenReturn("org.apache.qpid");
    assertEquals("Unexpected reply for matching log level and same logger name",
                 FilterReply.DENY,
                 filter.decide(event));

    when(event.getLoggerName()).thenReturn("org.apache.qpid.foo");
    assertEquals("Unexpected reply for matching log level and not same logger name",
                 FilterReply.NEUTRAL,
                 filter.decide(event));
}
 
Example 3
Source File: ResponseUnwrapper.java    From halyard with Apache License 2.0 6 votes vote down vote up
private static void logTasks(List<DaemonTask> tasks, Set<String> loggedEvents) {
  // This is expensive, so don't check all tasks to log unless it's necessary.
  if (GlobalOptions.getGlobalOptions().getLog() == Level.OFF) {
    return;
  }

  for (DaemonTask task : tasks) {
    for (Object oEvent : task.getEvents()) {
      DaemonEvent event = (DaemonEvent) oEvent;
      String loggedEvent = formatLoggedDaemonTask(task, event);
      if (!loggedEvents.contains(loggedEvent)) {
        loggedEvents.add(loggedEvent);
        log.info(loggedEvent);
      }
    }
  }
}
 
Example 4
Source File: LogUtil.java    From libreveris with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static Level toLevel (final String str)
{
    switch (str.toUpperCase()) {
    case "ALL":
        return Level.ALL;

    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;

    default:
    case "OFF":
        return Level.OFF;
    }
}
 
Example 5
Source File: LoggerOutputStream.java    From NationStatesPlusPlus with MIT License 6 votes vote down vote up
@Override
public synchronized void flush() throws IOException {
	super.flush();
	String record = this.toString();
	super.reset();

	if (record.length() > 0 && !record.equals(separator) && level != Level.OFF) {
		if (level == Level.TRACE)
			log.trace(record);
		else if (level == Level.DEBUG)
			log.debug(record);
		else if (level == Level.INFO)
			log.info(record);
		else if (level == Level.WARN)
			log.warn(record);
		else if (level == Level.ERROR)
			log.error(record);
	}
}
 
Example 6
Source File: LoggerNameAndLevelFilter.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
public Level getEffectiveLevel(final Logger logger)
{
    if((_loggerName == null || "".equals(_loggerName) || Logger.ROOT_LOGGER_NAME.equals(_loggerName))
      || (_loggerName.endsWith(".*") && logger.getName().startsWith(_loggerName.substring(0,_loggerName.length()-2)))
      || _loggerName.equals(logger.getName()))
    {
        return _level;
    }
    else
    {
        return Level.OFF;
    }
}
 
Example 7
Source File: LogUtil.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Decode a string as a Level value.
 *
 * @param str the input string
 * @return the decoded Level value
 */
public static Level toLevel (final String str)
{
    switch (str.toUpperCase()) {
    case "ALL":
        return Level.ALL;

    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;

    default:
    case "OFF":
        return Level.OFF;
    }
}
 
Example 8
Source File: NoLoggingIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
protected Level getTestLogLevel() {
	return Level.OFF;
}
 
Example 9
Source File: ControlLoggerWindow.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected Pair<TextField, HBoxLayout> createEditComponents(String loggerName, Level level) {
    final TextField loggerNameField = componentsFactory.createComponent(TextField.class);
    loggerNameField.setValue(loggerName);
    loggerNameField.setEditable(false);
    loggerNameField.setFrame(this);
    loggerNameField.setWidth("100%");

    HBoxLayout buttonField = componentsFactory.createComponent(HBoxLayout.class);
    buttonField.setSpacing(true);

    for (Level logLevel : LoggingHelper.getLevels()) {
        if (logLevel != Level.OFF && logLevel != Level.ALL) {
            Button button = componentsFactory.createComponent(Button.class);
            button.setAction(
                    new AbstractAction("setLevel") {
                        @Override
                        public void actionPerform(Component component) {
                            levels.put(loggerName, logLevel);
                            HBoxLayout buttonPanel = (HBoxLayout) button.getParent();
                            for (Component childButton : buttonPanel.getComponents()) {
                                if (childButton instanceof Button) {
                                    childButton.setStyleName("c-logger-level loglevel-" + logLevel.toString());
                                }
                            }
                            button.setStyleName("c-logger-level loglevel-" + logLevel.toString() + " currentlevel");
                        }
                    });

            button.setCaption(logLevel.toString());
            if (logLevel == level) {
                button.setStyleName("c-logger-level loglevel-" + logLevel.toString() + " currentlevel");
            } else {
                button.setStyleName("c-logger-level loglevel-" + logLevel.toString());
            }
            buttonField.add(button);
        }
    }

    levels.put(loggerName, level);

    return new Pair<>(loggerNameField, buttonField);
}