I am using PatternLayout in log4j 2.5. I also want to record timestamps of nanoseconds.
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="nanotimestamp = %nano %n"/>
</Console>
</Appenders>
And Java code
public static void main(String[] args) throws Exception {
for(int = 0; i< 4; i++){
logger.info("Hi");
try {
Thread.sleep(1000);
}
}
}
And the result:
nanotimestamp = 0
nanotimestamp = 0
nanotimestamp = 0
nanotimestamp = 0
Why is timestamp equal to 0? How can I get a nanosecond timestamp? Thanks.
source
share