Yuvi
Yuvi

Reputation: 41

Printing Time in every log print

In java,is there any way i can Print the Time of execution of that log statement in Logger

3    [main] DEBUG Main.class  -305
3    [main] DEBUG Main.class  -307
3    [main] DEBUG Main.class  -311


3[24-2-2016 12:00:00]    [main] DEBUG Main.class  -305 794
3[24-2-2016 12:00:01]    [main] DEBUG Main.class  -307
3[24-2-2016 12:00:02]    [main] DEBUG Main.class  -311

Upvotes: 0

Views: 1301

Answers (1)

Pawan B
Pawan B

Reputation: 4623

You can use log4j for implementing logging in your application.

You can go through this tutorial on log4j .

logs generated are like this :

2014-07-02 20:52:39 DEBUG HelloExample:19 - This is debug : mkyong
2014-07-02 20:52:39 INFO  HelloExample:23 - This is info : mkyong
2014-07-02 20:52:39 WARN  HelloExample:26 - This is warn : mkyong
2014-07-02 20:52:39 ERROR HelloExample:27 - This is error : mkyong
2014-07-02 20:52:39 FATAL HelloExample:28 - This is fatal : mkyong

Upvotes: 1

Related Questions