当前位置: 首页>>代码示例>>Java>>正文


Java FileHandler.publish方法代码示例

本文整理汇总了Java中java.util.logging.FileHandler.publish方法的典型用法代码示例。如果您正苦于以下问题:Java FileHandler.publish方法的具体用法?Java FileHandler.publish怎么用?Java FileHandler.publish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.logging.FileHandler的用法示例。


在下文中一共展示了FileHandler.publish方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFileHandler

import java.util.logging.FileHandler; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:CheckZombieLockTest.java

示例2: publish

import java.util.logging.FileHandler; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod")
@Override public void publish(LogRecord record) {
    FileHandler delegate0 = delegate;

    if (delegate0 != null)
        delegate0.publish(record);
}
 
开发者ID:apache,项目名称:ignite,代码行数:9,代码来源:JavaLoggerFileHandler.java

示例3: testPublish

import java.util.logging.FileHandler; //导入方法依赖的package包/类
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());
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:14,代码来源:OldFileHandlerTest.java

示例4: testClose

import java.util.logging.FileHandler; //导入方法依赖的package包/类
public void testClose() throws Exception {
    FileHandler h = new FileHandler("%t/log/stringPublish");
    h.publish(r);
    h.close();
    assertFileContent(TEMPPATH + SEP + "log", "stringPublish", h
            .getFormatter());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:8,代码来源:OldFileHandlerTest.java

示例5: testLock

import java.util.logging.FileHandler; //导入方法依赖的package包/类
public void testLock() throws Exception {
    FileOutputStream output = new FileOutputStream(TEMPPATH + SEP + "log"
            + SEP + "java1.test.0");
    FileHandler h = new FileHandler();
    h.publish(r);
    h.close();
    assertFileContent(TEMPPATH + SEP + "log", "java1.test.0", h
            .getFormatter(), "UTF-8");
    output.close();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:FileHandlerTest.java

示例6: testLock

import java.util.logging.FileHandler; //导入方法依赖的package包/类
public void testLock() throws Exception {
    FileOutputStream output = new FileOutputStream(TEMPPATH + SEP + "log"
            + SEP + "java1.test.0");
    FileHandler h = new FileHandler();
    h.publish(r);
    h.close();
    assertFileContent(TEMPPATH + SEP + "log", "java1.test.0", h
            .getFormatter());
    output.close();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:11,代码来源:FileHandlerTest.java

示例7: testFileHandlerString

import java.util.logging.FileHandler; //导入方法依赖的package包/类
public void testFileHandlerString() throws Exception {
    // test if unique ids not specified, it will append at the end
    // no generation number is used
    FileHandler h = new FileHandler("%t/log/string");
    FileHandler h2 = new FileHandler("%t/log/string");
    FileHandler h3 = new FileHandler("%t/log/string");
    FileHandler h4 = new FileHandler("%t/log/string");
    h.publish(r);
    h2.publish(r);
    h3.publish(r);
    h4.publish(r);
    h.close();
    h2.close();
    h3.close();
    h4.close();
    assertFileContent(TEMPPATH + SEP + "log", "string", h.getFormatter(), "UTF-8");
    assertFileContent(TEMPPATH + SEP + "log", "string.1", h.getFormatter(), "UTF-8");
    assertFileContent(TEMPPATH + SEP + "log", "string.2", h.getFormatter(), "UTF-8");
    assertFileContent(TEMPPATH + SEP + "log", "string.3", h.getFormatter(), "UTF-8");

    // default is append mode
    FileHandler h6 = new FileHandler("%t/log/string%u.log");
    h6.publish(r);
    h6.close();
    FileHandler h7 = new FileHandler("%t/log/string%u.log");
    h7.publish(r);
    h7.close();
    try {
        assertFileContent(TEMPPATH + SEP + "log", "string0.log", h
                .getFormatter(), "UTF-8");
        fail("should assertion failed");
    } catch (Error e) {
    }
    File file = new File(TEMPPATH + SEP + "log");
    assertTrue(file.list().length <= 2);

    // test unique ids
    FileHandler h8 = new FileHandler("%t/log/%ustring%u.log");
    h8.publish(r);
    FileHandler h9 = new FileHandler("%t/log/%ustring%u.log");
    h9.publish(r);
    h9.close();
    h8.close();
    assertFileContent(TEMPPATH + SEP + "log", "0string0.log", h
            .getFormatter(), "UTF-8");
    assertFileContent(TEMPPATH + SEP + "log", "1string1.log", h
            .getFormatter(), "UTF-8");
    file = new File(TEMPPATH + SEP + "log");
    assertTrue(file.list().length <= 2);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:51,代码来源:FileHandlerTest.java

示例8: testFileHandlerString

import java.util.logging.FileHandler; //导入方法依赖的package包/类
public void testFileHandlerString() throws Exception {
    // test if unique ids not specified, it will append at the end
    // no generation number is used
    FileHandler h = new FileHandler("%t/log/string");
    FileHandler h2 = new FileHandler("%t/log/string");
    FileHandler h3 = new FileHandler("%t/log/string");
    FileHandler h4 = new FileHandler("%t/log/string");
    h.publish(r);
    h2.publish(r);
    h3.publish(r);
    h4.publish(r);
    h.close();
    h2.close();
    h3.close();
    h4.close();
    assertFileContent(TEMPPATH + SEP + "log", "string", h.getFormatter());
    assertFileContent(TEMPPATH + SEP + "log", "string.1", h.getFormatter());
    assertFileContent(TEMPPATH + SEP + "log", "string.2", h.getFormatter());
    assertFileContent(TEMPPATH + SEP + "log", "string.3", h.getFormatter());

    // default is append mode
    FileHandler h6 = new FileHandler("%t/log/string%u.log");
    h6.publish(r);
    h6.close();
    FileHandler h7 = new FileHandler("%t/log/string%u.log");
    h7.publish(r);
    h7.close();
    try {
        assertFileContent(TEMPPATH + SEP + "log", "string0.log", h
                .getFormatter());
        fail("should assertion failed");
    } catch (Error e) {
    }
    File file = new File(TEMPPATH + SEP + "log");
    assertTrue(file.list().length <= 2);

    // test unique ids
    FileHandler h8 = new FileHandler("%t/log/%ustring%u.log");
    h8.publish(r);
    FileHandler h9 = new FileHandler("%t/log/%ustring%u.log");
    h9.publish(r);
    h9.close();
    h8.close();
    assertFileContent(TEMPPATH + SEP + "log", "0string0.log", h
            .getFormatter());
    assertFileContent(TEMPPATH + SEP + "log", "1string1.log", h
            .getFormatter());
    file = new File(TEMPPATH + SEP + "log");
    assertTrue(file.list().length <= 2);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:51,代码来源:FileHandlerTest.java


注:本文中的java.util.logging.FileHandler.publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。