This section illustrates you how to set filter on a logger handler in Java. Generally, Filter is a program that provides the facility to get data if the certain conditions are satisfied otherwise don't get any data. In other words, you get data to be filtered.
Logger handler provides the filtering facility that means when you set a filter on a logger object, the filter determines which data to be published or not. The filter facility deals those data that are recognized with the logger object or certain conditions are verify otherwise couldn't published those data.
Descriptions of program:
Program creates a logger object that assists for filtering the data and it has three classes as: Num, NumFilter and SetFilterLogger class. The SetFilterLogger class is a main class and other are inner classes. The Num class gets and returns given numbers and NumFilter class provides the facility for filtering data that implements a Filter. In this class, you give the certain conditions for filtering the number. This program shows result that are greater or equal to 20 with the help of logMessn() method.
Descriptions of code:
This is the interface of java.util.logging package that assists the fragment control over logger object. This fragments provided by log levels. Each Logger object filtered associated with the filter. The log records checked by isLoggable method should be published that provides Boolean types value either true or false. If returns false then LogRecord discard.
Above method returns the parameters of LogRecord object.
This is the constructor of Object class. This class extends the import java.lang.Object package. This class provides all arrays, objects and implementing the method.
Here is the code of program:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: February 22, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles