Show TOC

FormatterLocate this document in the navigation structure

Use

Each log destination type can print messages in different formats: TraceFormatter , XMLFormatter , and ListFormatter .

Features

TraceFormatter

  • A human readable format.

  • The most commonly used formatter when you want to understand quickly what is happening with the application.

  • The default pattern: %24d %-40l [%t] %s: %m

    The corresponding output is:

    Jan 01, 2007 10:10:00 PM com.sapmarkets.FooClass.fooMethod [main] Fatal: A sample fatal message.

    For example, if the pattern becomes %24d %l [%s] %m , the corresponding output is:

    Jan 01, 2001 10:10:00 PM com.sapmarkets.FooClass.fooMethod [Fatal] A sample fatal message.

  • The number in the pattern denotes the width of a field.

    In the first example: " %-40l " indicates a limit of 40 chars for the location name ( com.sapmarkets.FooClass.fooMethod ) that will be right-aligned (with a minus sign). If the length of a string exceeds the defined width, the string will be truncated.

    In the second example: " %l " displays the full string that will be left-aligned.

The table below describes the meaning of the placeholders:

Placeholder

Description

%d

Timestamp in readable form.

%l

The location of origin (for example, com.sapmarkets.FooClass.fooMethod ).

%c

The log controller through which the message is issued (for example, com.sapmarkets.FooClass ).

%t

The thread that emits the message.

%s

The message severity.

%m

The formatted message text.

%I

The Message ID.

%p

The time stamp in milliseconds (for example, since January 1, 1970 00:00:00 GMT ).

%g

The group identification.

XMLFormatter

Suitable for file transfer to be further processed in other applications.

<record>
     <id>10.48.27.165:4A5AB2:E99D2EDAFF:-8000</id>
     <time>Mon Jan 01 22:00:00 PDT 2001</time>
     <source>com.sapmarkets.FooClass</source>
     <location>com.sapmarkets.FooClass.fooMethod</location>
     <thread>main</thread>
     <severity>Fatal</severity>
     <msg-type>Plain</msg-type>
     <msg-clear>A sample fatal message</msg-clear>
</record>
            

The DTD of the result is:

<!ELEMENT table (id, time, source, location, thread, group?, severity, relatives?, msg-type, msg-code?, bundle?, msg-clear?, args?)>
             <!ELEMENT id (#PCDATA)>
             <!ELEMENT time (#PCDATA)>
             <!ELEMENT source (#PCDATA)>
             <!ELEMENT location (#PCDATA)>
             <!ELEMENT thread (#PCDATA)>
             <!ELEMENT group (id, level, indent)>
             <!ELEMENT level (#PCDATA)>
             <!ELEMENT indent (#PCDATA)>
             <!ELEMENT severity (#PCDATA)>
             <!ELEMENT relatives (relative+)>
             <!ELEMENT relative (#PCDATA)>
             <!ELEMENT msg-type (#PCDATA)>
             <!ELEMENT msg-code (#PCDATA)>
             <!ELEMENT bundle (#PCDATA)>
             <!ELEMENT msg-clear (#PCDATA)>
             <!ELEMENT args (arg+)>
             <!ELEMENT arg (#PCDATA)>
            

ListFormatter

  • The output of this format serves like a router. That is, it sends the data for further processing by another application, instead of being read directly by the user.

  • Simple hash-separated fields to be processed mainly with the Log Viewer.

    More information: Log Viewer

  • Sample output of the same result is:

    #2.0#2008 04 15 18:47:29:778#+0300#Info#/System/Changes/configtool#

    ###C0000A37462200020000000201BE2893###configtool########Thread[Thread-6,5,main]#Plain##

    Number of debug nodes was changed from 1 to 1 for Instance - ID543210#

  • The order of the fields, delimited by the hash sign is:

    • Version (of the ListFormatter)

    • Message ID

    • Timestamp

    • Source name (log controller)

    • Thread ID

    • Location name (the actual code location that generates the message)

    • Group indentation

    • Message severity

    • Message Type (PLAIN or JAVA)

    • Message Code

    • ResourceBundle name

    • Message

    • Number of arguments

    • Arguments