Example usage for java.util.logging Handler getErrorManager

List of usage examples for java.util.logging Handler getErrorManager

Introduction

In this page you can find the example usage for java.util.logging Handler getErrorManager.

Prototype

public ErrorManager getErrorManager() 

Source Link

Document

Retrieves the ErrorManager for this Handler.

Usage

From source file:MailHandlerDemo.java

/**
 * Gets a formatting string describing the given handler.
 *
 * @param prefix the output prefix./*from www .ja  va2  s.  c o m*/
 * @param err the error stream.
 * @param h the handler.
 * @return the formatted string.
 */
private static String toString(String prefix, PrintStream err, Handler h) {
    StringBuilder buf = new StringBuilder();
    buf.append(h.getClass().getName());
    try {
        if (h instanceof MailHandler) {
            MailHandler mh = (MailHandler) h;
            buf.append(", ").append(mh.getSubject());
        }
    } catch (SecurityException error) {
        err.print(prefix + ": ");
        error.printStackTrace(err);
    }

    try {
        buf.append(", ").append(h.getFormatter());
    } catch (SecurityException error) {
        err.print(prefix + ": ");
        error.printStackTrace(err);
    }

    try {
        if (h instanceof MailHandler) {
            MailHandler mh = (MailHandler) h;
            buf.append(", ").append(Arrays.toString(mh.getAttachmentFormatters()));
        }
    } catch (SecurityException error) {
        err.print(prefix + ": ");
        error.printStackTrace(err);
    }

    try {
        buf.append(", ").append(h.getLevel());
    } catch (SecurityException error) {
        err.print(prefix + ": ");
        error.printStackTrace(err);
    }

    try {
        buf.append(", ").append(h.getFilter());
    } catch (SecurityException error) {
        err.print(prefix + ": ");
        error.printStackTrace(err);
    }

    try {
        buf.append(", ").append(h.getErrorManager());
    } catch (SecurityException error) {
        err.print(prefix + ": ");
        error.printStackTrace(err);
    }

    buf.append(", ").append(toString(h.getClass().getClassLoader()));
    return buf.toString();
}