United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6381464 : SimpleFormatter should use one single line format

Details
Type:
Enhancement
Submit Date:
2006-02-06
Status:
Closed
Updated Date:
2014-04-09
Project Name:
JDK
Resolved Date:
2011-04-21
Component:
core-libs
OS:
generic,windows_xp
Sub-Component:
java.util.logging
CPU:
x86,generic
Priority:
P5
Resolution:
Fixed
Affected Versions:
6,7
Fixed Versions:

Related Reports
Duplicate:
Relates:
Relates:

Sub Tasks

Description
A DESCRIPTION OF THE REQUEST :
Default Java Logging Format uses two lines per log output.. Default logging format should be brief and without line seperators.

JUSTIFICATION :
Since default format uses a two line logging output, it is hard to read and follow by the developers. logging output seems cluttured. Although it is possible to define custom Formatters, many third party Java libraries uses the default format of the Java logger and does not bother making a custom formatter (such as Tomcat 5.5.x). i see developers  use log4j or other kind of third party logger mechanisms just because default format is ugly.
Default output first should tell what is the Level and the actual output, the other details (time, class, method) shoud be appended later. Of course the order of the default output format is my personal opininon..

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Default Java looger format it should be single line.

ACTUAL -
Formatter uses two lines per log output. Output seems confusing.

---------- BEGIN SOURCE ----------
package com.myCompany.project;

import java.util.logging.Logger;

public class DefaultLoggerTest {

    public static void main(String[] args) {
        Logger logger = Logger.getLogger(DefaultLoggerTest.class.getName());
        logger.info("Testing default format..");
    }
}

output:

Feb 3, 2006 11:40:39 PM com.myCompany.project.DefaultLoggerTest main
INFO: Testing default format..

can be shown in one such as like this (something better, or more brief can be written, this is just an example)

INFO: Testing default format.. [DefaultLoggerTest | main | Feb 3, 2006 11:40:39 PM | com.myCompany.project]
---------- END SOURCE ----------
This bug fix adds the following new SDK/JDK test:

    java/util/logging/SimpleFormatterFormat.java

This test is not valid for execution until JDK7-B138.
If this test is executed on older bits, it will fail.
However, this entry will make that failure appear on
the known fail_list.

                                    

Comments
EVALUATION

There is no single format that will satisfy all customers.  In JDK 7,
we will support a customizable format string specified in a
"java.util.logging.SimpleFormatter.format" property using the
java.util.Formatter format string syntax.

If the specified format string is illegal, it falls back to use the default
format rather than throwing an exception so that errors that occur while
handling logging events - such as logging misconfiguration, network error
- do not cause the application using logging to terminate prematurely.  
Same convention has been used in handling other configuration errors
in the logging framework (e.g. a handler is configured to use a non-existence
formatter class).
 
Example usage: To print 1-line only with the log level and the log message,
set the following in the logging.properties:
  java.util.logging.SimpleFormatter.format="%4$s: %5$s%n"
                                     
2011-03-25
EVALUATION

There are applications that depend on the current output format.
The default format will remain the same so that it won't break existing
applications and also the default format remains implementation-specific
as different JDK implementation may have different default format.
                                     
2011-03-25
EVALUATION

Changeset URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/d2bbdd709307
                                     
2011-03-29



Hardware and Software, Engineered to Work Together