Logger getFilter() Method in Java with Examples Last Updated : 20 Mar, 2019 Comments Improve Suggest changes Like Article Like Report The getFilter() method of the Logger class is used to get the current filter for this Logger instance. A Filter is useful to filter out log messages. we can say that filter decide the message gets logged or not. Filters are represented by the Java interface java.util.logging.Filter Syntax: public Filter getFilter() Parameters: This method accepts do not accepts any parameter. Return value: This method returns the current filter for this Logger. Below programs illustrate the getFilter() method: Program 1: Java // Java program to demonstrate // Logger.getFilter() method import java.util.logging.*; import java.io.IOException; public class GFG { public static void main(String[] args) throws SecurityException, IOException { // create a logger Logger logger = Logger.getLogger("com.core"); // set a new filter logger.setFilter(new Filter() { @Override public boolean isLoggable(LogRecord record) { return true; } }); // get Filter Filter filter = logger.getFilter(); // check filter is null or not by printing System.out.println("Filter = " + filter); } } Output: The output printed on eclipse IDE is shown below- Program 2: Java // Java program to demonstrate // Logger.getFilter() method import java.util.logging.*; import java.io.IOException; public class GFG { public static void main(String[] args) throws SecurityException, IOException { // create a logger Logger logger = Logger.getLogger("com.javacode.core"); // set a new filter logger.setFilter(new MyFilter()); // get Filter Filter filter = logger.getFilter(); // check filter is null or not by printing System.out.println("Filter = " + filter); } } class MyFilter implements Filter { public boolean isLoggable(LogRecord record) { return false; } } Output: The output printed on eclipse IDE is shown below- Reference: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#getFilter() Comment More infoAdvertise with us Next Article Logger getFilter() Method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java - util package Java-Functions Java-Logger Practice Tags : Java Similar Reads Logger getLogger() Method in Java with Examples The getLogger() method of a Logger class used find or create a logger. If there is a logger exists with the passed name then the method will return that logger else method will create a new logger with that name and return it. There are two types of getLogger() method depending upon no of the parame 4 min read Logger finer() method in Java with Examples The finer() method of a Logger class used to Log an FINER message.This method is used to pass FINER types logs to all the registered output Handler objects. FINER message: FINER outputs a detailed tracing message and may include logging calls regarding method entering, exiting, throwing exceptions. 3 min read Logger getHandler() Method in Java with Examples The getHandlers() method of the Logger class is used to get the Handlers linked with this logger. Handler is used to taking care of the actual logging. one or more Handler can be added to a Logger. When messages are logged via the Logger, the messages are forwarded to the Handler. This method is hel 2 min read Logger fine() method in Java with Examples The fine() method of a Logger class used to Log a FINE message. This method is used to pass FINE types logs to all the registered output Handler objects. FINE, FINER and FINEST provide tracking information as when what is happening/ has happened in our application. FINE displays the most important m 3 min read Logger getLevel() method in Java with Examples The getLevel() method of the Logger class in Java is used to get the log Level that has been specified for this Logger instance. Every Logger has specific log levels and if the result is null, which means that this logger's effective level will be inherited from its parent. Log Levels: The log level 2 min read Like