Example usage for java.util.logging Handler getFilter

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

Introduction

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

Prototype

public Filter getFilter() 

Source Link

Document

Get the current Filter for this Handler .

Usage

From source file:MailHandlerDemo.java

/**
 * Gets a formatting string describing the given handler.
 *
 * @param prefix the output prefix.//from   w w w  . j a  v a2s  . 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();
}