Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Date format in log4j

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have configured my log4j as below.

and in log i am getting date as below

2014-07-16 07:13:07,470

I need the date format as below.
2014-07-16 07:13:07 GMT

Can any one please let me know what modification should i do?

Thanks
Kala
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Look here: http://www.vipan.com/htdocs/log4jhelp.html

Regards
Polo
 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I expect that somewhere in that very long document it mentions how to format timestamps in log4j. But the short answer is that you follow the same rules that Java does in the SimpleDateFormat class. (Follow the link to the API documentation.)
 
Kala Saseendran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have went through simpledateformat. that is how i come up with the existing date pattern. I have change dthe pattern as belwo



and this is giving me dat as below

2014-07-17 05:46:05 GMT+00:00

How ever as the offset is +00:00 i dont want it to be printed and the output should be as below

2014-07-17 05:46:05 GMT


I tried various patterns. None of them are working.


Thanks
Kala
 
Paul Clapham
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how about:

 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!