File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes System.out to display date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "System.out to display date" Watch "System.out to display date" New topic

System.out to display date

Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
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
("' at '' -- '");
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.



David O'Meara

Joined: Mar 06, 2001
Posts: 13459

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.

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
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...

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You can make your own method and/or class that does this.


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: System.out to display date
It's not a secret anymore!