logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 40145] New: - PatternLayout - %r doesn't do what the documentation says.
Date Mon, 31 Jul 2006 17:09:33 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40145>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40145

           Summary: PatternLayout - %r doesn't do what the documentation
                    says.
           Product: Log4j
           Version: 1.2
          Platform: All
        OS/Version: other
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Layout
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: mark.atwell@jpmorgan.com


According to the Javadocs: %r - Used to output the number of milliseconds 
elapsed since the start of the application until the creation of the logging 
event.

In practice the initial time is actually initialised from when the 
PatternLayout class is loaded and the static initialisers are fired.

Consider the following rather contrived and paraphrased example:

public class MyClass
{
 static final Logger logger = Logger.getLogger(MyClass.class);

 public static void main(String[] args) throws Exception
 {
  BasicConfigurator.configure();

  Thread.sleep(10 * 1000);

  logger.info("Hello, World!");
 }
}

The time reported at Hello, World is actually very close to zero.

AFAIK it seems to be practically impossible to know the app/JVM launch-time, 
nonetheless it could be better.

Solutions I guess would be for the configuration call or, probably better, one 
of the Logger.getLogger() calls initialised the time or forces load of the 
PatternLayout class-load?

A workaround is to log something early and of course many apps do this so it 
isn't a noted problem.

In practice this is probably not unique to any platform or possibly even 
version of Log4J.

Do any of the other implementations suffer from the same problem.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message