Class DBFormatter


  • public class DBFormatter
    extends Formatter
    This Formatter provides support for formatting LogRecords that will help Database Logging.

    Typically this Formatter will be associated with a DBHandler (a handler meant to handle Database logging). DBFormatter takes a LogRecord and converts it to a Formatted string which DBHandler can understand.

    • Constructor Detail

      • DBFormatter

        public DBFormatter()
        Creates DBFormatter object
    • Method Detail

      • getHead

        public String getHead​(Handler h)
        Returns the set of all fields converted into a COMMA seperated string. A typical sql query for logging a record looks like this.

        insert into table "amSSO_access" (time, data, loginid, domain, level, ipAddress, hostname) values('10:10:10', '10th June, 2002', ..., ..., ...)

        The getHead method returns back the set of all fields converted into a COMMA seperated string. It is the duty of the formatter to fetch the all field set from the LogManager and convert into a COMMA seperated string. By doing this the handler can be kept independent of the all field and selected field set.

        Overrides:
        getHead in class Formatter
        Parameters:
        h - The target handler (can be null)
        Returns:
        the set of all fields converted into a COMMA seperated string.
      • getTail

        public String getTail​(Handler h)
        Returns a null string whenever called.
        Overrides:
        getTail in class Formatter
        Parameters:
        h - The target handler (can be null)
        Returns:
        a null string whenever called.
      • format

        public String format​(LogRecord logRecord)
        Simply return the value from calling formatMessage. All DBFormatting is now handled directly in DBHandler.
        Specified by:
        format in class Formatter
        Parameters:
        logRecord - The LogRecord to format
        Returns:
        A String that represents the formatted LogRecord