Issue
In log4j.properties
I can set PatternLayout
e.g. ("[%p] %c - %m - %d %n")
Is there any symbol (%something) which returns current time in milliseconds?
Solution
There is no Log4J symbol that does exactly what you want.
%d
returns the current date with a given pattern, defined by a SimpleDateFormat
(the pattern you put between the brackets), but doesn't give you the time in millis.
%r
gives the number of milliseconds since the start of execution.
One possible way of achieving what you want is to extend the behaviour of Log4j, it's quite a bit more complex, but if it's absolutely necessary... here you go:
Customize log4j (edit: no longer online?)
Customize log4j (edit: 2018 alternative)
Edit: Keep in mind that, from your comment, if you need to figure out time differences between executions in different machines, you have to make sure the clocks of the machines are synchronized, or it'll be leading you to wrong conclusions.
Answered By - pcalcao
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.