src/share/classes/java/util/logging/Logger.java

Print this page
rev 6281 : 8005263: Logging APIs takes a Supplier<String> for message


  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 package java.util.logging;
  28 
  29 import java.util.*;
  30 import java.util.concurrent.CopyOnWriteArrayList;
  31 import java.security.*;
  32 import java.lang.ref.WeakReference;


  33 
  34 /**
  35  * A Logger object is used to log messages for a specific
  36  * system or application component.  Loggers are normally named,
  37  * using a hierarchical dot-separated namespace.  Logger names
  38  * can be arbitrary strings, but they should normally be based on
  39  * the package name or class name of the logged component, such
  40  * as java.net or javax.swing.  In addition it is possible to create
  41  * "anonymous" Loggers that are not stored in the Logger namespace.
  42  * <p>
  43  * Logger objects may be obtained by calls on one of the getLogger
  44  * factory methods.  These will either create a new Logger or
  45  * return a suitable existing Logger. It is important to note that
  46  * the Logger returned by one of the {@code getLogger} factory methods
  47  * may be garbage collected at any time if a strong reference to the
  48  * Logger is not kept.
  49  * <p>
  50  * Logging messages will be forwarded to registered Handler
  51  * objects, which can forward the messages to a variety of
  52  * destinations, including consoles, files, OS logs, etc.


  79  * record should be published.  If that passes it will then publish
  80  * the LogRecord to its output Handlers.  By default, loggers also
  81  * publish to their parent's Handlers, recursively up the tree.
  82  * <p>
  83  * Each Logger may have a ResourceBundle name associated with it.
  84  * The named bundle will be used for localizing logging messages.
  85  * If a Logger does not have its own ResourceBundle name, then
  86  * it will inherit the ResourceBundle name from its parent,
  87  * recursively up the tree.
  88  * <p>
  89  * Most of the logger output methods take a "msg" argument.  This
  90  * msg argument may be either a raw value or a localization key.
  91  * During formatting, if the logger has (or inherits) a localization
  92  * ResourceBundle and if the ResourceBundle has a mapping for the msg
  93  * string, then the msg string is replaced by the localized value.
  94  * Otherwise the original msg string is used.  Typically, formatters use
  95  * java.text.MessageFormat style formatting to format parameters, so
  96  * for example a format string "{0} {1}" would format two parameters
  97  * as strings.
  98  * <p>






  99  * When mapping ResourceBundle names to ResourceBundles, the Logger
 100  * will first try to use the Thread's ContextClassLoader.  If that
 101  * is null it will try the SystemClassLoader instead.  As a temporary
 102  * transition feature in the initial implementation, if the Logger is
 103  * unable to locate a ResourceBundle from the ContextClassLoader or
 104  * SystemClassLoader the Logger will also search up the class stack
 105  * and use successive calling ClassLoaders to try to locate a ResourceBundle.
 106  * (This call stack search is to allow containers to transition to
 107  * using ContextClassLoaders and is likely to be removed in future
 108  * versions.)
 109  * <p>
 110  * Formatting (including localization) is the responsibility of
 111  * the output Handler, which will typically call a Formatter.
 112  * <p>
 113  * Note that formatting need not occur synchronously.  It may be delayed
 114  * until a LogRecord is actually written to an external sink.
 115  * <p>
 116  * The logging methods are grouped in five main categories:
 117  * <ul>
 118  * <li><p>


 526                 break;
 527             }
 528 
 529             logger = logger.getParent();
 530         }
 531     }
 532 
 533     // private support method for logging.
 534     // We fill in the logger name, resource bundle name, and
 535     // resource bundle and then call "void log(LogRecord)".
 536     private void doLog(LogRecord lr) {
 537         lr.setLoggerName(name);
 538         String ebname = getEffectiveResourceBundleName();
 539         if (ebname != null) {
 540             lr.setResourceBundleName(ebname);
 541             lr.setResourceBundle(findResourceBundle(ebname));
 542         }
 543         log(lr);
 544     }
 545 
















 546 
 547     //================================================================
 548     // Start of convenience methods WITHOUT className and methodName
 549     //================================================================
 550 
 551     /**
 552      * Log a message, with no arguments.
 553      * <p>
 554      * If the logger is currently enabled for the given message
 555      * level then the given message is forwarded to all the
 556      * registered output Handler objects.
 557      * <p>
 558      * @param   level   One of the message level identifiers, e.g., SEVERE
 559      * @param   msg     The string message (or a key in the message catalog)
 560      */
 561     public void log(Level level, String msg) {
 562         if (level.intValue() < levelValue || levelValue == offValue) {
 563             return;
 564         }
 565         LogRecord lr = new LogRecord(level, msg);
 566         doLog(lr);
 567     }
 568 
 569     /**

















 570      * Log a message, with one object parameter.
 571      * <p>
 572      * If the logger is currently enabled for the given message
 573      * level then a corresponding LogRecord is created and forwarded
 574      * to all the registered output Handler objects.
 575      * <p>
 576      * @param   level   One of the message level identifiers, e.g., SEVERE
 577      * @param   msg     The string message (or a key in the message catalog)
 578      * @param   param1  parameter to the message
 579      */
 580     public void log(Level level, String msg, Object param1) {
 581         if (level.intValue() < levelValue || levelValue == offValue) {
 582             return;
 583         }
 584         LogRecord lr = new LogRecord(level, msg);
 585         Object params[] = { param1 };
 586         lr.setParameters(params);
 587         doLog(lr);
 588     }
 589 


 615      * which is forwarded to all registered output handlers.
 616      * <p>
 617      * Note that the thrown argument is stored in the LogRecord thrown
 618      * property, rather than the LogRecord parameters property.  Thus is it
 619      * processed specially by output Formatters and is not treated
 620      * as a formatting parameter to the LogRecord message property.
 621      * <p>
 622      * @param   level   One of the message level identifiers, e.g., SEVERE
 623      * @param   msg     The string message (or a key in the message catalog)
 624      * @param   thrown  Throwable associated with log message.
 625      */
 626     public void log(Level level, String msg, Throwable thrown) {
 627         if (level.intValue() < levelValue || levelValue == offValue) {
 628             return;
 629         }
 630         LogRecord lr = new LogRecord(level, msg);
 631         lr.setThrown(thrown);
 632         doLog(lr);
 633     }
 634 























 635     //================================================================
 636     // Start of convenience methods WITH className and methodName
 637     //================================================================
 638 
 639     /**
 640      * Log a message, specifying source class and method,
 641      * with no arguments.
 642      * <p>
 643      * If the logger is currently enabled for the given message
 644      * level then the given message is forwarded to all the
 645      * registered output Handler objects.
 646      * <p>
 647      * @param   level   One of the message level identifiers, e.g., SEVERE
 648      * @param   sourceClass    name of class that issued the logging request
 649      * @param   sourceMethod   name of method that issued the logging request
 650      * @param   msg     The string message (or a key in the message catalog)
 651      */
 652     public void logp(Level level, String sourceClass, String sourceMethod, String msg) {
 653         if (level.intValue() < levelValue || levelValue == offValue) {
 654             return;
 655         }
 656         LogRecord lr = new LogRecord(level, msg);
 657         lr.setSourceClassName(sourceClass);
 658         lr.setSourceMethodName(sourceMethod);
 659         doLog(lr);
 660     }
 661 
 662     /**
























 663      * Log a message, specifying source class and method,
 664      * with a single object parameter to the log message.
 665      * <p>
 666      * If the logger is currently enabled for the given message
 667      * level then a corresponding LogRecord is created and forwarded
 668      * to all the registered output Handler objects.
 669      * <p>
 670      * @param   level   One of the message level identifiers, e.g., SEVERE
 671      * @param   sourceClass    name of class that issued the logging request
 672      * @param   sourceMethod   name of method that issued the logging request
 673      * @param   msg      The string message (or a key in the message catalog)
 674      * @param   param1    Parameter to the log message.
 675      */
 676     public void logp(Level level, String sourceClass, String sourceMethod,
 677                                                 String msg, Object param1) {
 678         if (level.intValue() < levelValue || levelValue == offValue) {
 679             return;
 680         }
 681         LogRecord lr = new LogRecord(level, msg);
 682         lr.setSourceClassName(sourceClass);


 726      * as a formatting parameter to the LogRecord message property.
 727      * <p>
 728      * @param   level   One of the message level identifiers, e.g., SEVERE
 729      * @param   sourceClass    name of class that issued the logging request
 730      * @param   sourceMethod   name of method that issued the logging request
 731      * @param   msg     The string message (or a key in the message catalog)
 732      * @param   thrown  Throwable associated with log message.
 733      */
 734     public void logp(Level level, String sourceClass, String sourceMethod,
 735                                                         String msg, Throwable thrown) {
 736         if (level.intValue() < levelValue || levelValue == offValue) {
 737             return;
 738         }
 739         LogRecord lr = new LogRecord(level, msg);
 740         lr.setSourceClassName(sourceClass);
 741         lr.setSourceMethodName(sourceMethod);
 742         lr.setThrown(thrown);
 743         doLog(lr);
 744     }
 745 































 746 
 747     //=========================================================================
 748     // Start of convenience methods WITH className, methodName and bundle name.
 749     //=========================================================================
 750 
 751     // Private support method for logging for "logrb" methods.
 752     // We fill in the logger name, resource bundle name, and
 753     // resource bundle and then call "void log(LogRecord)".
 754     private void doLog(LogRecord lr, String rbname) {
 755         lr.setLoggerName(name);
 756         if (rbname != null) {
 757             lr.setResourceBundleName(rbname);
 758             lr.setResourceBundle(findResourceBundle(rbname));
 759         }
 760         log(lr);
 761     }
 762 
 763     /**
 764      * Log a message, specifying source class, method, and resource bundle name
 765      * with no arguments.


1130         if (Level.FINER.intValue() < levelValue) {
1131             return;
1132         }
1133         log(Level.FINER, msg);
1134     }
1135 
1136     /**
1137      * Log a FINEST message.
1138      * <p>
1139      * If the logger is currently enabled for the FINEST message
1140      * level then the given message is forwarded to all the
1141      * registered output Handler objects.
1142      * <p>
1143      * @param   msg     The string message (or a key in the message catalog)
1144      */
1145     public void finest(String msg) {
1146         if (Level.FINEST.intValue() < levelValue) {
1147             return;
1148         }
1149         log(Level.FINEST, msg);




























































































































1150     }
1151 
1152     //================================================================
1153     // End of convenience methods
1154     //================================================================
1155 
1156     /**
1157      * Set the log level specifying which message levels will be
1158      * logged by this logger.  Message levels lower than this
1159      * value will be discarded.  The level value Level.OFF
1160      * can be used to turn off logging.
1161      * <p>
1162      * If the new level is null, it means that this node should
1163      * inherit its level from its nearest ancestor with a specific
1164      * (non-null) level value.
1165      *
1166      * @param newLevel   the new value for the log level (may be null)
1167      * @exception  SecurityException  if a security manager exists and if
1168      *             the caller does not have LoggingPermission("control").
1169      */




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 package java.util.logging;
  28 
  29 import java.util.*;
  30 import java.util.concurrent.CopyOnWriteArrayList;
  31 import java.security.*;
  32 import java.lang.ref.WeakReference;
  33 import java.util.function.Block;
  34 import java.util.function.Supplier;
  35 
  36 /**
  37  * A Logger object is used to log messages for a specific
  38  * system or application component.  Loggers are normally named,
  39  * using a hierarchical dot-separated namespace.  Logger names
  40  * can be arbitrary strings, but they should normally be based on
  41  * the package name or class name of the logged component, such
  42  * as java.net or javax.swing.  In addition it is possible to create
  43  * "anonymous" Loggers that are not stored in the Logger namespace.
  44  * <p>
  45  * Logger objects may be obtained by calls on one of the getLogger
  46  * factory methods.  These will either create a new Logger or
  47  * return a suitable existing Logger. It is important to note that
  48  * the Logger returned by one of the {@code getLogger} factory methods
  49  * may be garbage collected at any time if a strong reference to the
  50  * Logger is not kept.
  51  * <p>
  52  * Logging messages will be forwarded to registered Handler
  53  * objects, which can forward the messages to a variety of
  54  * destinations, including consoles, files, OS logs, etc.


  81  * record should be published.  If that passes it will then publish
  82  * the LogRecord to its output Handlers.  By default, loggers also
  83  * publish to their parent's Handlers, recursively up the tree.
  84  * <p>
  85  * Each Logger may have a ResourceBundle name associated with it.
  86  * The named bundle will be used for localizing logging messages.
  87  * If a Logger does not have its own ResourceBundle name, then
  88  * it will inherit the ResourceBundle name from its parent,
  89  * recursively up the tree.
  90  * <p>
  91  * Most of the logger output methods take a "msg" argument.  This
  92  * msg argument may be either a raw value or a localization key.
  93  * During formatting, if the logger has (or inherits) a localization
  94  * ResourceBundle and if the ResourceBundle has a mapping for the msg
  95  * string, then the msg string is replaced by the localized value.
  96  * Otherwise the original msg string is used.  Typically, formatters use
  97  * java.text.MessageFormat style formatting to format parameters, so
  98  * for example a format string "{0} {1}" would format two parameters
  99  * as strings.
 100  * <p>
 101  * Since 1.8, a set of methods alternatively take a "msgSupplier" instead of
 102  * a "msg" argument.  This version takes a {@link Supplier}{@code
 103  * <String>} function which is invoked to construct desired log message
 104  * only when the message actually to be logged after checking the effective
 105  * log level thus eliminate unnecessary message construction.
 106  * <p>
 107  * When mapping ResourceBundle names to ResourceBundles, the Logger
 108  * will first try to use the Thread's ContextClassLoader.  If that
 109  * is null it will try the SystemClassLoader instead.  As a temporary
 110  * transition feature in the initial implementation, if the Logger is
 111  * unable to locate a ResourceBundle from the ContextClassLoader or
 112  * SystemClassLoader the Logger will also search up the class stack
 113  * and use successive calling ClassLoaders to try to locate a ResourceBundle.
 114  * (This call stack search is to allow containers to transition to
 115  * using ContextClassLoaders and is likely to be removed in future
 116  * versions.)
 117  * <p>
 118  * Formatting (including localization) is the responsibility of
 119  * the output Handler, which will typically call a Formatter.
 120  * <p>
 121  * Note that formatting need not occur synchronously.  It may be delayed
 122  * until a LogRecord is actually written to an external sink.
 123  * <p>
 124  * The logging methods are grouped in five main categories:
 125  * <ul>
 126  * <li><p>


 534                 break;
 535             }
 536 
 537             logger = logger.getParent();
 538         }
 539     }
 540 
 541     // private support method for logging.
 542     // We fill in the logger name, resource bundle name, and
 543     // resource bundle and then call "void log(LogRecord)".
 544     private void doLog(LogRecord lr) {
 545         lr.setLoggerName(name);
 546         String ebname = getEffectiveResourceBundleName();
 547         if (ebname != null) {
 548             lr.setResourceBundleName(ebname);
 549             lr.setResourceBundle(findResourceBundle(ebname));
 550         }
 551         log(lr);
 552     }
 553 
 554     // private support method for logging.
 555     // message and LogRecord are only constucted when it really need to
 556     // be logged
 557     private void doLog(Level level, Supplier<String> msgSupplier,
 558                        Block<LogRecord> staging) {
 559         if (level.intValue() < levelValue || levelValue == offValue) {
 560             return;
 561         }
 562         LogRecord lr = new LogRecord(level, msgSupplier.get());
 563         if (staging != null ) {
 564             staging.accept(lr);
 565         }
 566         // Set logger name and resource bundle
 567         doLog(lr);
 568     }
 569 
 570 
 571     //================================================================
 572     // Start of convenience methods WITHOUT className and methodName
 573     //================================================================
 574 
 575     /**
 576      * Log a message, with no arguments.
 577      * <p>
 578      * If the logger is currently enabled for the given message
 579      * level then the given message is forwarded to all the
 580      * registered output Handler objects.
 581      * <p>
 582      * @param   level   One of the message level identifiers, e.g., SEVERE
 583      * @param   msg     The string message (or a key in the message catalog)
 584      */
 585     public void log(Level level, String msg) {
 586         if (level.intValue() < levelValue || levelValue == offValue) {
 587             return;
 588         }
 589         LogRecord lr = new LogRecord(level, msg);
 590         doLog(lr);
 591     }
 592 
 593     /**
 594      * Log a message, which is only to be constructed if the logging level
 595      * is such that the message will actually be logged.
 596      * <p>
 597      * If the logger is currently enabled for the given message
 598      * level then the message is constructed by invoking the provided
 599      * supplier function and forwarded to all the registered output
 600      * Handler objects.
 601      * <p>
 602      * @param   level   One of the message level identifiers, e.g., SEVERE
 603      * @param   msgSupplier   A function, which when called, produces the
 604      *                        desired log message
 605      */
 606     public void log(Level level, Supplier<String> msgSupplier) {
 607         doLog(level, msgSupplier, null);
 608     }
 609 
 610     /**
 611      * Log a message, with one object parameter.
 612      * <p>
 613      * If the logger is currently enabled for the given message
 614      * level then a corresponding LogRecord is created and forwarded
 615      * to all the registered output Handler objects.
 616      * <p>
 617      * @param   level   One of the message level identifiers, e.g., SEVERE
 618      * @param   msg     The string message (or a key in the message catalog)
 619      * @param   param1  parameter to the message
 620      */
 621     public void log(Level level, String msg, Object param1) {
 622         if (level.intValue() < levelValue || levelValue == offValue) {
 623             return;
 624         }
 625         LogRecord lr = new LogRecord(level, msg);
 626         Object params[] = { param1 };
 627         lr.setParameters(params);
 628         doLog(lr);
 629     }
 630 


 656      * which is forwarded to all registered output handlers.
 657      * <p>
 658      * Note that the thrown argument is stored in the LogRecord thrown
 659      * property, rather than the LogRecord parameters property.  Thus is it
 660      * processed specially by output Formatters and is not treated
 661      * as a formatting parameter to the LogRecord message property.
 662      * <p>
 663      * @param   level   One of the message level identifiers, e.g., SEVERE
 664      * @param   msg     The string message (or a key in the message catalog)
 665      * @param   thrown  Throwable associated with log message.
 666      */
 667     public void log(Level level, String msg, Throwable thrown) {
 668         if (level.intValue() < levelValue || levelValue == offValue) {
 669             return;
 670         }
 671         LogRecord lr = new LogRecord(level, msg);
 672         lr.setThrown(thrown);
 673         doLog(lr);
 674     }
 675 
 676     /**
 677      * Log a in-time constructed message, with associated Throwable information.
 678      * <p>
 679      * If the logger is currently enabled for the given message level then the
 680      * message is constructed by invoking the provided supplier function. The
 681      * message and the given {@link Throwable} are then stored in a {@link
 682      * LogRecord} which is forwarded to all registered output handlers.
 683      * <p>
 684      * Note that the thrown argument is stored in the LogRecord thrown
 685      * property, rather than the LogRecord parameters property.  Thus is it
 686      * processed specially by output Formatters and is not treated
 687      * as a formatting parameter to the LogRecord message property.
 688      * <p>
 689      * @param   level   One of the message level identifiers, e.g., SEVERE
 690      * @param   msgSupplier   A function, which when called, produces the
 691      *                        desired log message
 692      * @param   thrown  Throwable associated with log message.
 693      * @since   1.8
 694      */
 695     public void logEx(Level level, Supplier<String> msgSupplier, Throwable thrown) {
 696         doLog(level, msgSupplier, lr -> lr.setThrown(thrown));
 697     }
 698 
 699     //================================================================
 700     // Start of convenience methods WITH className and methodName
 701     //================================================================
 702 
 703     /**
 704      * Log a message, specifying source class and method,
 705      * with no arguments.
 706      * <p>
 707      * If the logger is currently enabled for the given message
 708      * level then the given message is forwarded to all the
 709      * registered output Handler objects.
 710      * <p>
 711      * @param   level   One of the message level identifiers, e.g., SEVERE
 712      * @param   sourceClass    name of class that issued the logging request
 713      * @param   sourceMethod   name of method that issued the logging request
 714      * @param   msg     The string message (or a key in the message catalog)
 715      */
 716     public void logp(Level level, String sourceClass, String sourceMethod, String msg) {
 717         if (level.intValue() < levelValue || levelValue == offValue) {
 718             return;
 719         }
 720         LogRecord lr = new LogRecord(level, msg);
 721         lr.setSourceClassName(sourceClass);
 722         lr.setSourceMethodName(sourceMethod);
 723         doLog(lr);
 724     }
 725 
 726     /**
 727      * Log a in-time constructed message, specifying source class and method,
 728      * with no arguments.
 729      * <p>
 730      * If the logger is currently enabled for the given message
 731      * level then the message is constructed by invoking the provided
 732      * supplier function and forwarded to all the registered output
 733      * Handler objects.
 734      * <p>
 735      * @param   level   One of the message level identifiers, e.g., SEVERE
 736      * @param   sourceClass    name of class that issued the logging request
 737      * @param   sourceMethod   name of method that issued the logging request
 738      * @param   msgSupplier   A function, which when called, produces the
 739      *                        desired log message
 740      * @since   1.8
 741      */
 742     public void logp(Level level, String sourceClass, String sourceMethod,
 743                      Supplier<String> msgSupplier) {
 744         doLog(level, msgSupplier, lr -> {
 745             lr.setSourceClassName(sourceClass);
 746             lr.setSourceMethodName(sourceMethod);
 747         });
 748     }
 749 
 750     /**
 751      * Log a message, specifying source class and method,
 752      * with a single object parameter to the log message.
 753      * <p>
 754      * If the logger is currently enabled for the given message
 755      * level then a corresponding LogRecord is created and forwarded
 756      * to all the registered output Handler objects.
 757      * <p>
 758      * @param   level   One of the message level identifiers, e.g., SEVERE
 759      * @param   sourceClass    name of class that issued the logging request
 760      * @param   sourceMethod   name of method that issued the logging request
 761      * @param   msg      The string message (or a key in the message catalog)
 762      * @param   param1    Parameter to the log message.
 763      */
 764     public void logp(Level level, String sourceClass, String sourceMethod,
 765                                                 String msg, Object param1) {
 766         if (level.intValue() < levelValue || levelValue == offValue) {
 767             return;
 768         }
 769         LogRecord lr = new LogRecord(level, msg);
 770         lr.setSourceClassName(sourceClass);


 814      * as a formatting parameter to the LogRecord message property.
 815      * <p>
 816      * @param   level   One of the message level identifiers, e.g., SEVERE
 817      * @param   sourceClass    name of class that issued the logging request
 818      * @param   sourceMethod   name of method that issued the logging request
 819      * @param   msg     The string message (or a key in the message catalog)
 820      * @param   thrown  Throwable associated with log message.
 821      */
 822     public void logp(Level level, String sourceClass, String sourceMethod,
 823                      String msg, Throwable thrown) {
 824         if (level.intValue() < levelValue || levelValue == offValue) {
 825             return;
 826         }
 827         LogRecord lr = new LogRecord(level, msg);
 828         lr.setSourceClassName(sourceClass);
 829         lr.setSourceMethodName(sourceMethod);
 830         lr.setThrown(thrown);
 831         doLog(lr);
 832     }
 833 
 834     /**
 835      * Log a in-time constructed message, specifying source class and method,
 836      * with associated Throwable information.
 837      * <p>
 838      * If the logger is currently enabled for the given message level then the
 839      * message is constructed by invoking the provided supplier function. The
 840      * message and the given {@link Throwable} are then stored in a {@link
 841      * LogRecord} which is forwarded to all registered output handlers.
 842      * <p>
 843      * Note that the thrown argument is stored in the LogRecord thrown
 844      * property, rather than the LogRecord parameters property.  Thus is it
 845      * processed specially by output Formatters and is not treated
 846      * as a formatting parameter to the LogRecord message property.
 847      * <p>
 848      * @param   level   One of the message level identifiers, e.g., SEVERE
 849      * @param   sourceClass    name of class that issued the logging request
 850      * @param   sourceMethod   name of method that issued the logging request
 851      * @param   msgSupplier   A function, which when called, produces the
 852      *                        desired log message
 853      * @param   thrown  Throwable associated with log message.
 854      * @since   1.8
 855      */
 856     public void logpEx(Level level, String sourceClass, String sourceMethod,
 857                        Supplier<String> msgSupplier, Throwable thrown) {
 858         doLog(level, msgSupplier, lr -> {
 859             lr.setSourceClassName(sourceClass);
 860             lr.setSourceMethodName(sourceMethod);
 861             lr.setThrown(thrown);
 862         });
 863     }
 864 
 865 
 866     //=========================================================================
 867     // Start of convenience methods WITH className, methodName and bundle name.
 868     //=========================================================================
 869 
 870     // Private support method for logging for "logrb" methods.
 871     // We fill in the logger name, resource bundle name, and
 872     // resource bundle and then call "void log(LogRecord)".
 873     private void doLog(LogRecord lr, String rbname) {
 874         lr.setLoggerName(name);
 875         if (rbname != null) {
 876             lr.setResourceBundleName(rbname);
 877             lr.setResourceBundle(findResourceBundle(rbname));
 878         }
 879         log(lr);
 880     }
 881 
 882     /**
 883      * Log a message, specifying source class, method, and resource bundle name
 884      * with no arguments.


1249         if (Level.FINER.intValue() < levelValue) {
1250             return;
1251         }
1252         log(Level.FINER, msg);
1253     }
1254 
1255     /**
1256      * Log a FINEST message.
1257      * <p>
1258      * If the logger is currently enabled for the FINEST message
1259      * level then the given message is forwarded to all the
1260      * registered output Handler objects.
1261      * <p>
1262      * @param   msg     The string message (or a key in the message catalog)
1263      */
1264     public void finest(String msg) {
1265         if (Level.FINEST.intValue() < levelValue) {
1266             return;
1267         }
1268         log(Level.FINEST, msg);
1269     }
1270 
1271     //=======================================================================
1272     // Start of simple convenience methods using level names as method names
1273     // and use Supplier<String>
1274     //=======================================================================
1275 
1276     /**
1277      * Log a SEVERE message, which is only to be constructed if the logging
1278      * level is such that the message will actually be logged.
1279      * <p>
1280      * If the logger is currently enabled for the SEVERE message
1281      * level then the message is constructed by invoking the provided
1282      * supplier function and forwarded to all the registered output
1283      * Handler objects.
1284      * <p>
1285      * @param   msgSupplier   A function, which when called, produces the
1286      *                        desired log message
1287      * @since   1.8
1288      */
1289     public void severe(Supplier<String> msgSupplier) {
1290         log(Level.SEVERE, msgSupplier);
1291     }
1292 
1293     /**
1294      * Log a WARNING message, which is only to be constructed if the logging
1295      * level is such that the message will actually be logged.
1296      * <p>
1297      * If the logger is currently enabled for the WARNING message
1298      * level then the message is constructed by invoking the provided
1299      * supplier function and forwarded to all the registered output
1300      * Handler objects.
1301      * <p>
1302      * @param   msgSupplier   A function, which when called, produces the
1303      *                        desired log message
1304      * @since   1.8
1305      */
1306     public void warning(Supplier<String> msgSupplier) {
1307         log(Level.WARNING, msgSupplier);
1308     }
1309 
1310     /**
1311      * Log a INFO message, which is only to be constructed if the logging
1312      * level is such that the message will actually be logged.
1313      * <p>
1314      * If the logger is currently enabled for the INFO message
1315      * level then the message is constructed by invoking the provided
1316      * supplier function and forwarded to all the registered output
1317      * Handler objects.
1318      * <p>
1319      * @param   msgSupplier   A function, which when called, produces the
1320      *                        desired log message
1321      * @since   1.8
1322      */
1323     public void info(Supplier<String> msgSupplier) {
1324         log(Level.INFO, msgSupplier);
1325     }
1326 
1327     /**
1328      * Log a CONFIG message, which is only to be constructed if the logging
1329      * level is such that the message will actually be logged.
1330      * <p>
1331      * If the logger is currently enabled for the CONFIG message
1332      * level then the message is constructed by invoking the provided
1333      * supplier function and forwarded to all the registered output
1334      * Handler objects.
1335      * <p>
1336      * @param   msgSupplier   A function, which when called, produces the
1337      *                        desired log message
1338      * @since   1.8
1339      */
1340     public void config(Supplier<String> msgSupplier) {
1341         log(Level.CONFIG, msgSupplier);
1342     }
1343 
1344     /**
1345      * Log a FINE message, which is only to be constructed if the logging
1346      * level is such that the message will actually be logged.
1347      * <p>
1348      * If the logger is currently enabled for the FINE message
1349      * level then the message is constructed by invoking the provided
1350      * supplier function and forwarded to all the registered output
1351      * Handler objects.
1352      * <p>
1353      * @param   msgSupplier   A function, which when called, produces the
1354      *                        desired log message
1355      * @since   1.8
1356      */
1357     public void fine(Supplier<String> msgSupplier) {
1358         log(Level.FINE, msgSupplier);
1359     }
1360 
1361     /**
1362      * Log a FINER message, which is only to be constructed if the logging
1363      * level is such that the message will actually be logged.
1364      * <p>
1365      * If the logger is currently enabled for the FINER message
1366      * level then the message is constructed by invoking the provided
1367      * supplier function and forwarded to all the registered output
1368      * Handler objects.
1369      * <p>
1370      * @param   msgSupplier   A function, which when called, produces the
1371      *                        desired log message
1372      * @since   1.8
1373      */
1374     public void finer(Supplier<String> msgSupplier) {
1375         log(Level.FINER, msgSupplier);
1376     }
1377 
1378     /**
1379      * Log a FINEST message, which is only to be constructed if the logging
1380      * level is such that the message will actually be logged.
1381      * <p>
1382      * If the logger is currently enabled for the FINEST message
1383      * level then the message is constructed by invoking the provided
1384      * supplier function and forwarded to all the registered output
1385      * Handler objects.
1386      * <p>
1387      * @param   msgSupplier   A function, which when called, produces the
1388      *                        desired log message
1389      * @since   1.8
1390      */
1391     public void finest(Supplier<String> msgSupplier) {
1392         log(Level.FINEST, msgSupplier);
1393     }
1394 
1395     //================================================================
1396     // End of convenience methods
1397     //================================================================
1398 
1399     /**
1400      * Set the log level specifying which message levels will be
1401      * logged by this logger.  Message levels lower than this
1402      * value will be discarded.  The level value Level.OFF
1403      * can be used to turn off logging.
1404      * <p>
1405      * If the new level is null, it means that this node should
1406      * inherit its level from its nearest ancestor with a specific
1407      * (non-null) level value.
1408      *
1409      * @param newLevel   the new value for the log level (may be null)
1410      * @exception  SecurityException  if a security manager exists and if
1411      *             the caller does not have LoggingPermission("control").
1412      */