Java Code Examples for java.util.logging.FileHandler#publish()

The following examples show how to use java.util.logging.FileHandler#publish() . 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: CheckZombieLockTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 2
Source File: CheckZombieLockTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 3
Source File: CheckZombieLockTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 4
Source File: CheckZombieLockTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 5
Source File: CheckZombieLockTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 6
Source File: CheckZombieLockTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 7
Source File: CheckZombieLockTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 8
Source File: CheckZombieLockTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 9
Source File: CheckZombieLockTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 10
Source File: CheckZombieLockTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 11
Source File: JavaLoggerFileHandler.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod")
@Override public void publish(LogRecord record) {
    FileHandler delegate0 = delegate;

    if (delegate0 != null)
        delegate0.publish(record);
}
 
Example 12
Source File: CheckZombieLockTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static FileHandler createFileHandler(File writableDir) throws SecurityException,
        RuntimeException, IOException {
    // Test 1: make sure we can create FileHandler in writable directory
    try {
        FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log");
        handler.publish(new LogRecord(Level.INFO, handler.toString()));
        handler.flush();
        return handler;
    } catch (IOException ex) {
        throw new RuntimeException("Test failed: should have been able"
                + " to create FileHandler for " + "%t/" + WRITABLE_DIR
                + "/log.log in writable directory.", ex);
    }
}
 
Example 13
Source File: OldFileHandlerTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testPublish() throws Exception {
    LogRecord[] r = new LogRecord[] { new LogRecord(Level.CONFIG, "msg__"),
            new LogRecord(Level.WARNING, "message"),
            new LogRecord(Level.INFO, "message for"),
            new LogRecord(Level.FINE, "message for test") };
    for (int i = 0; i < r.length; i++) {
        handler = new FileHandler("%t/log/stringPublish");
        handler.publish(r[i]);
        handler.close();
        assertFileContent(TEMPPATH + SEP + "log", "stringPublish",
                new LogRecord[] { r[i] }, handler.getFormatter());
    }
}
 
Example 14
Source File: OldFileHandlerTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testClose() throws Exception {
    FileHandler h = new FileHandler("%t/log/stringPublish");
    h.publish(r);
    h.close();
    assertFileContent(TEMPPATH + SEP + "log", "stringPublish", h
            .getFormatter());
}