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

The following examples show how to use ch.qos.logback.classic.Level#ALL . 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: 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 3
Source File: DiagnosticLogSystem.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
public void startLoggingExtraction(final ExtractionId extractionId) {
    logger.info("Diagnostics attempting to redirect extraction logs: " + extractionId.toUniqueString());
    final File logDir = new File(logDirectory, "extractions");
    logDir.mkdirs();
    final File logFile = new File(logDir, extractionId.toUniqueString() + ".txt");
    extractionLogger = new DiagnosticLogger(logFile, Level.ALL);
    extractionLogger.startLogging();
}
 
Example 4
Source File: LoggingUtils.java    From heat with Apache License 2.0 5 votes vote down vote up
/**
 * This method sets the log level (logback).
 */
public void setLogLevel() {
    logLevel = System.getProperty("logLevel", LOG_LEVEL_INFO);
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    Level logLevelSetting;
    switch (logLevel.toLowerCase()) {
    case LOG_LEVEL_ERROR:
        logLevelSetting = Level.ERROR;
        break;
    case LOG_LEVEL_WARN:
        logLevelSetting = Level.WARN;
        break;
    case LOG_LEVEL_ALL:
        logLevelSetting = Level.ALL;
        break;
    case LOG_LEVEL_TRACE_LOG:
        logLevelSetting = Level.TRACE;
        break;
    case LOG_LEVEL_INFO:
        logLevelSetting = Level.INFO;
        break;
    case LOG_LEVEL_DEBUG:
        logLevelSetting = Level.DEBUG;
        break;
    default:
        logLevelSetting = Level.INFO;
        break;
    }
    root.setLevel(logLevelSetting);
}
 
Example 5
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 6
Source File: KafkaAppenderTest.java    From logback-kafka-appender with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppendUsesKeying() {
    when(encoder.encode(any(ILoggingEvent.class))).thenReturn(new byte[]{0x00, 0x00});
    unit.start();
    final LoggingEvent evt = new LoggingEvent("fqcn",ctx.getLogger("logger"), Level.ALL, "message", null, new Object[0]);
    unit.append(evt);
    verify(deliveryStrategy).send(any(KafkaProducer.class), any(ProducerRecord.class), eq(evt), any(FailedDeliveryCallback.class));
    verify(keyingStrategy).createKey(same(evt));
    verify(deliveryStrategy).send(any(KafkaProducer.class), any(ProducerRecord.class), eq(evt), any(FailedDeliveryCallback.class));
}
 
Example 7
Source File: KafkaAppenderTest.java    From logback-kafka-appender with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppendUsesPreConfiguredPartition() {
    when(encoder.encode(any(ILoggingEvent.class))).thenReturn(new byte[]{0x00, 0x00});
    ArgumentCaptor<ProducerRecord> producerRecordCaptor = ArgumentCaptor.forClass(ProducerRecord.class);
    unit.setPartition(1);
    unit.start();
    final LoggingEvent evt = new LoggingEvent("fqcn", ctx.getLogger("logger"), Level.ALL, "message", null, new Object[0]);
    unit.append(evt);
    verify(deliveryStrategy).send(any(KafkaProducer.class), producerRecordCaptor.capture(), eq(evt), any(FailedDeliveryCallback.class));
    final ProducerRecord value = producerRecordCaptor.getValue();
    assertThat(value.partition(), equalTo(1));
}
 
Example 8
Source File: KafkaAppenderTest.java    From logback-kafka-appender with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeferredAppend() {
    when(encoder.encode(any(ILoggingEvent.class))).thenReturn(new byte[]{0x00, 0x00});
    unit.start();
    final LoggingEvent deferredEvent = new LoggingEvent("fqcn",ctx.getLogger("org.apache.kafka.clients.logger"), Level.ALL, "deferred message", null, new Object[0]);
    unit.doAppend(deferredEvent);

    verify(deliveryStrategy, never()).send(any(KafkaProducer.class), any(ProducerRecord.class), eq(deferredEvent), any(FailedDeliveryCallback.class));

    final LoggingEvent evt = new LoggingEvent("fqcn",ctx.getLogger("logger"), Level.ALL, "message", null, new Object[0]);
    unit.doAppend(evt);
    verify(deliveryStrategy).send(any(KafkaProducer.class), any(ProducerRecord.class), eq(deferredEvent), any(FailedDeliveryCallback.class));
    verify(deliveryStrategy).send(any(KafkaProducer.class), any(ProducerRecord.class), eq(evt), any(FailedDeliveryCallback.class));
}
 
Example 9
Source File: HostNameKeyingStrategyTest.java    From logback-kafka-appender with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldPartitionByHostName() {
    ctx.putProperty(CoreConstants.HOSTNAME_KEY, "localhost");
    unit.setContext(ctx);
    final ILoggingEvent evt = new LoggingEvent("fqcn", ctx.getLogger("logger"), Level.ALL, "msg", null, new Object[0]);
    Assert.assertThat(unit.createKey(evt), Matchers.equalTo(ByteBuffer.allocate(4).putInt("localhost".hashCode()).array()));
}
 
Example 10
Source File: ContextNameKeyingStrategyTest.java    From logback-kafka-appender with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldPartitionByEventThreadName() {
    ctx.setName(LOGGER_CONTEXT_NAME);
    unit.setContext(ctx);
    final ILoggingEvent evt = new LoggingEvent("fqcn", ctx.getLogger("logger"), Level.ALL, "msg", null, new Object[0]);
    Assert.assertThat(unit.createKey(evt), Matchers.equalTo(ByteBuffer.allocate(4).putInt(LOGGER_CONTEXT_NAME.hashCode()).array()));
}
 
Example 11
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);
}
 
Example 12
Source File: LoggerNameKeyingStrategyTest.java    From logback-kafka-appender with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldPartitionByLoggerName() {
    final ILoggingEvent evt = new LoggingEvent("fqcn", ctx.getLogger("logger"), Level.ALL, "msg", null, new Object[0]);
    Assert.assertThat(unit.createKey(evt), Matchers.equalTo(ByteBuffer.allocate(4).putInt("logger".hashCode()).array()));
}
 
Example 13
Source File: ThreadNameKeyingStrategyTest.java    From logback-kafka-appender with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldPartitionByEventThreadName() {
    final String threadName = Thread.currentThread().getName();
    final ILoggingEvent evt = new LoggingEvent("fqcn", ctx.getLogger("logger"), Level.ALL, "msg", null, new Object[0]);
    Assert.assertThat(unit.createKey(evt), Matchers.equalTo(ByteBuffer.allocate(4).putInt(threadName.hashCode()).array()));
}
 
Example 14
Source File: LogFixture.java    From gocd with Apache License 2.0 4 votes vote down vote up
public static LogFixture logFixtureForLogger(String name) {
    return new LogFixture((Logger) LoggerFactory.getLogger(name), Level.ALL);
}