• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.out to display date

 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • 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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • 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
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can make your own method and/or class that does this.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic