< prev index next >

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

Print this page




  49  * the format string specified in the system property will be used.
  50  * If this property is not defined or the given format string
  51  * is {@linkplain java.util.IllegalFormatException illegal},
  52  * the default format is implementation-specific.
  53  *
  54  * @since 1.4
  55  * @see java.util.Formatter
  56  */
  57 
  58 public class SimpleFormatter extends Formatter {
  59 
  60     // format string for printing the log record
  61     static String getLoggingProperty(String name) {
  62         return LogManager.getLogManager().getProperty(name);
  63     }
  64 
  65     private final String format =
  66         SurrogateLogger.getSimpleFormat(SimpleFormatter::getLoggingProperty);
  67 
  68     /**





  69      * Format the given LogRecord.
  70      * <p>
  71      * The formatting can be customized by specifying the format string
  72      * in the <a href="#formatting">
  73      * {@code java.util.logging.SimpleFormatter.format}</a> property.
  74      * The given {@code LogRecord} will be formatted as if by calling:
  75      * <pre>
  76      *    {@link String#format String.format}(format, date, source, logger, level, message, thrown);
  77      * </pre>
  78      * where the arguments are:<br>
  79      * <ol>
  80      * <li>{@code format} - the {@link java.util.Formatter
  81      *     java.util.Formatter} format string specified in the
  82      *     {@code java.util.logging.SimpleFormatter.format} property
  83      *     or the default format.</li>
  84      * <li>{@code date} - a {@link ZonedDateTime} object representing
  85      *     {@linkplain LogRecord#getInstant() event time} of the log record
  86      *      in the {@link ZoneId#systemDefault()} system time zone.</li>
  87      * <li>{@code source} - a string representing the caller, if available;
  88      *     otherwise, the logger's name.</li>




  49  * the format string specified in the system property will be used.
  50  * If this property is not defined or the given format string
  51  * is {@linkplain java.util.IllegalFormatException illegal},
  52  * the default format is implementation-specific.
  53  *
  54  * @since 1.4
  55  * @see java.util.Formatter
  56  */
  57 
  58 public class SimpleFormatter extends Formatter {
  59 
  60     // format string for printing the log record
  61     static String getLoggingProperty(String name) {
  62         return LogManager.getLogManager().getProperty(name);
  63     }
  64 
  65     private final String format =
  66         SurrogateLogger.getSimpleFormat(SimpleFormatter::getLoggingProperty);
  67 
  68     /**
  69      * Create a {@code SimpleFormatter}.
  70      */
  71     public SimpleFormatter() {}
  72 
  73     /**
  74      * Format the given LogRecord.
  75      * <p>
  76      * The formatting can be customized by specifying the format string
  77      * in the <a href="#formatting">
  78      * {@code java.util.logging.SimpleFormatter.format}</a> property.
  79      * The given {@code LogRecord} will be formatted as if by calling:
  80      * <pre>
  81      *    {@link String#format String.format}(format, date, source, logger, level, message, thrown);
  82      * </pre>
  83      * where the arguments are:<br>
  84      * <ol>
  85      * <li>{@code format} - the {@link java.util.Formatter
  86      *     java.util.Formatter} format string specified in the
  87      *     {@code java.util.logging.SimpleFormatter.format} property
  88      *     or the default format.</li>
  89      * <li>{@code date} - a {@link ZonedDateTime} object representing
  90      *     {@linkplain LogRecord#getInstant() event time} of the log record
  91      *      in the {@link ZoneId#systemDefault()} system time zone.</li>
  92      * <li>{@code source} - a string representing the caller, if available;
  93      *     otherwise, the logger's name.</li>


< prev index next >