Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java Batch design question

Status
Not open for further replies.

osubb

Programmer
Jan 21, 2004
11
US
I'm developing a batch program in java and was looking at different ways to implement error logging.

I will need to output many error msgs in many different objects. At this point I see three different ways of doing this.

1) Create a class that has opening, closing, and writing methods for the file. I would need to initialize a reference in all classes (which is a lot) that need to use this object.

2) Create the file and just have a reference to the File in each class/object.

3) Create a Static Class and use it some what like we use the System.out class. I would have to initialize the class (open the file), and then also close it before the pgm is exited.

Any comments on which is better and why? I'm leaning towards the static class.

Larry
 
Why using a file?

If you just use System.out and System.err, the user may send the messages and errors to two files with

java YourApp 1>messages.txt 2>messages.err

or into one file with

java YourApp 1>messages.txt 2>&1


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top