Example usage for java.util.logging FileHandler getClass

List of usage examples for java.util.logging FileHandler getClass

Introduction

In this page you can find the example usage for java.util.logging FileHandler getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:pub.vrtech.common.logs.jdk.JdkLoggerAdapter.java

public JdkLoggerAdapter() {
    try {//from   www . j av  a  2  s .c  o  m
        InputStream in = Thread.currentThread().getContextClassLoader()
                .getResourceAsStream("logging.properties");
        if (in != null) {
            LogManager.getLogManager().readConfiguration(in);
        } else {
            System.err.println("No such logging.properties in classpath for jdk logging config!");
        }
    } catch (Throwable t) {
        System.err.println("Failed to load logging.properties in classpath for jdk logging config, cause: "
                + t.getMessage());
    }
    try {
        Handler[] handlers = java.util.logging.Logger.getLogger(GLOBAL_LOGGER_NAME).getHandlers();
        for (Handler handler : handlers) {
            if (handler instanceof FileHandler) {
                FileHandler fileHandler = (FileHandler) handler;
                Field field = fileHandler.getClass().getField("files");
                File[] files = (File[]) field.get(fileHandler);
                if (files != null && files.length > 0) {
                    file = files[0];
                }
            }
        }
    } catch (Throwable t) {
    }
}