Keine Cache-Version

Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code LNG204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.
java.util.logging

Class SimpleFormatter


  • public class SimpleFormatter
    extends Formatter
    Print a brief summary of the LogRecord in a human readable format. The summary will typically be 1 or 2 lines.

    Configuration: The SimpleFormatter is initialized with the format string specified in the java.util.logging.SimpleFormatter.format property to format the log messages. This property can be defined in the logging properties configuration file or as a system property. If this property is set in both the logging properties and system properties, the format string specified in the system property will be used. If this property is not defined or the given format string is illegal, the default format is implementation-specific.

    Since:
    1.4
    See Also:
    Formatter
    • Constructor Detail

      • SimpleFormatter

        public SimpleFormatter()
    • Method Detail

      • format

        public String format(LogRecord record)
        Format the given LogRecord.

        The formatting can be customized by specifying the format string in the java.util.logging.SimpleFormatter.format property. The given LogRecord will be formatted as if by calling:

            String.format(format, date, source, logger, level, message, thrown);
         
        where the arguments are:
        1. format - the java.util.Formatter format string specified in the java.util.logging.SimpleFormatter.format property or the default format.
        2. date - a Date object representing event time of the log record.
        3. source - a string representing the caller, if available; otherwise, the logger's name.
        4. logger - the logger's name.
        5. level - the log level.
        6. message - the formatted log message returned from the Formatter.formatMessage(LogRecord) method. It uses java.text formatting and does not use the java.util.Formatter format argument.
        7. thrown - a string representing the throwable associated with the log record and its backtrace beginning with a newline character, if any; otherwise, an empty string.

        Some example formats:

        • java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"

          This prints 1 line with the log level (4$), the log message (5$) and the timestamp (1$) in a square bracket.

               WARNING: warning message [Tue Mar 22 13:11:31 PDT 2011]
               
        • java.util.logging.SimpleFormatter.format="%1$tc %2$s%n%4$s: %5$s%6$s%n"

          This prints 2 lines where the first line includes the timestamp (1$) and the source (2$); the second line includes the log level (4$) and the log message (5$) followed with the throwable and its backtrace (6$), if any:

               Tue Mar 22 13:11:31 PDT 2011 MyClass fatal
               SEVERE: several message with an exception
               java.lang.IllegalArgumentException: invalid argument
                       at MyClass.mash(MyClass.java:9)
                       at MyClass.crunch(MyClass.java:6)
                       at MyClass.main(MyClass.java:3)
               
        • java.util.logging.SimpleFormatter.format="%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%n"

          This prints 2 lines similar to the example above with a different date/time formatting and does not print the throwable and its backtrace:

               Mar 22, 2011 1:11:31 PM MyClass fatal
               SEVERE: several message with an exception
               

        This method can also be overridden in a subclass. It is recommended to use the Formatter.formatMessage(java.util.logging.LogRecord) convenience method to localize and format the message field.

        Specified by:
        format in class Formatter
        Parameters:
        record - the log record to be formatted.
        Returns:
        a formatted log record

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-java/util/logging/simpleformatter.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut