• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

System.out to display date

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I was wondering if someone could help with a little trick I wanted to do with the System.out.println in my Java classes.

Basically in Websphere, you don;t get a date/time before any system outs in your log files, which i would like, so I was wondering if anyone knew of a way I could tell 'Java' to oput the date/time on the start of any System.out. I've got a date format sorted:

Date today = new Date();
SimpleDateFormat sysDate = new SimpleDateFormat
("dd.mm.yyyy' at 'HH.mm.ss' -- '");
String strSystemDate = sysDate.format(today);

But what I don't want to have to do is put System.out.println(strSystemDate+"something else here..."); in every System.out

I was wondering if there is a way of saying, if System.out then start with strSystemDate. I know it sounds a little daft but iot would really help with my logging.

Cheers

K.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"KPS",
please see this previous warning regarding your display name.

We require display names to be two words: yourr first name, a space, then your last name. Fictitious names are not allowed. You'll notice everyone else follows these rules.

Please edit your profile and fix your display name, since accounts with invalid display names get deleted, often without warning.

The fact you already have 29 posts means your account will probably be closed soon, I'd update your profile immediately if I were you.

thanks,
Dave
 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Does you want to log every process in your application?
If yes, you can use log4j to do that so you can add the current date and time for every logging in your application.

Hope this help and correct me if I am wrong to understand what you want...

thanks
daniel
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can make your own method and/or class that does this.

Layne
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic