Search in sources :

Example 86 with LogRecord

use of java.util.logging.LogRecord in project netty by netty.

the class JdkLogger method log.

/**
     * Log the message at the specified level with the specified throwable if any.
     * This method creates a LogRecord and fills in caller date before calling
     * this instance's JDK14 logger.
     *
     * See bug report #13 for more details.
     */
private void log(String callerFQCN, Level level, String msg, Throwable t) {
    // millis and thread are filled by the constructor
    LogRecord record = new LogRecord(level, msg);
    record.setLoggerName(name());
    record.setThrown(t);
    fillCallerData(callerFQCN, record);
    logger.log(record);
}
Also used : LogRecord(java.util.logging.LogRecord)

Example 87 with LogRecord

use of java.util.logging.LogRecord in project generator by mybatis.

the class JdkLoggingImpl method error.

public void error(String s, Throwable e) {
    LogRecord lr = new LogRecord(Level.SEVERE, s);
    lr.setSourceClassName(log.getName());
    lr.setThrown(e);
    log.log(lr);
}
Also used : LogRecord(java.util.logging.LogRecord)

Example 88 with LogRecord

use of java.util.logging.LogRecord in project jersey by jersey.

the class MultiPartHeaderModificationTest method testLogMessage.

@Test
public void testLogMessage() {
    final WebTarget target = target().path("multipart/ten");
    MultiPartBean bean = new MultiPartBean("myname", "myvalue");
    MultiPart entity = new MultiPart().bodyPart(bean, new MediaType("x-application", "x-format")).bodyPart("", MediaType.APPLICATION_OCTET_STREAM_TYPE);
    final String UNSENT_HEADER_CHANGES = "Unsent header changes";
    try {
        target.request("text/plain").put(Entity.entity(entity, "multipart/mixed"), String.class);
        assertFalse("BadRequestException can not be thrown just in case JERSEY-2341 is not fixed.", messageLogged);
        LogRecord logRecord = findLogRecord(UNSENT_HEADER_CHANGES);
        assertNull(logRecord);
    } catch (BadRequestException brex) {
        assertTrue("BadRequestException can be thrown just in case JERSEY-2341 is not fixed.", messageLogged);
        LogRecord logRecord = findLogRecord(UNSENT_HEADER_CHANGES);
        assertNotNull("Missing LogRecord for message '" + UNSENT_HEADER_CHANGES + "'.", logRecord);
        assertThat(logRecord.getMessage(), containsString("MIME-Version"));
        assertThat(logRecord.getMessage(), containsString("Content-Type"));
    }
}
Also used : MultiPart(org.glassfish.jersey.media.multipart.MultiPart) LogRecord(java.util.logging.LogRecord) MediaType(javax.ws.rs.core.MediaType) BadRequestException(javax.ws.rs.BadRequestException) WebTarget(javax.ws.rs.client.WebTarget) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 89 with LogRecord

use of java.util.logging.LogRecord in project midpoint by Evolveum.

the class LoggingFeature method logMessage.

private static void logMessage(Logger logger, String message) {
    if (!logger.isLoggable(Level.FINE)) {
        return;
    }
    LogRecord lr = new LogRecord(Level.FINE, message);
    lr.setSourceClassName(logger.getName());
    lr.setSourceMethodName(null);
    lr.setLoggerName(logger.getName());
    logger.log(lr);
}
Also used : LogRecord(java.util.logging.LogRecord)

Example 90 with LogRecord

use of java.util.logging.LogRecord in project pcgen by PCGen.

the class PCGenStatusBar method setSourceLoadErrors.

public void setSourceLoadErrors(List<LogRecord> errors) {
    if (errors != null && !errors.isEmpty()) {
        int nerrors = 0;
        int nwarnings = 0;
        for (LogRecord logRecord : errors) {
            if (logRecord.getLevel().intValue() > Logging.WARNING.intValue()) {
                nerrors++;
            } else if (logRecord.getLevel().intValue() > Logging.INFO.intValue()) {
                nwarnings++;
            }
        }
        if (nerrors > 0) {
            loadStatusLabel.setIcon(Icons.Stop16.getImageIcon());
        } else if (nwarnings > 0) {
            loadStatusLabel.setIcon(Icons.Alert16.getImageIcon());
        } else {
            loadStatusLabel.setIcon(Icons.Ok16.getImageIcon());
        }
        loadStatusLabel.setToolTipText(nerrors + " errors and " + nwarnings + " warnings occurred while loading the sources");
    }
}
Also used : LogRecord(java.util.logging.LogRecord)

Aggregations

LogRecord (java.util.logging.LogRecord)370 Logger (java.util.logging.Logger)62 Test (org.junit.Test)61 Handler (java.util.logging.Handler)24 File (java.io.File)21 IOException (java.io.IOException)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)16 Level (java.util.logging.Level)16 StreamHandler (java.util.logging.StreamHandler)14 ConsoleHandler (java.util.logging.ConsoleHandler)13 ArrayList (java.util.ArrayList)12 Properties (java.util.Properties)11 Config (com.sun.enterprise.config.serverbeans.Config)10 Formatter (java.util.logging.Formatter)10 SimpleFormatter (java.util.logging.SimpleFormatter)10 LogRecordCollectingLogger (alma.acs.testsupport.LogRecordCollectingLogger)9 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)9 ActionReport (org.glassfish.api.ActionReport)9 HashMap (java.util.HashMap)7 Subscribe (com.google.common.eventbus.Subscribe)6