Hi Friends,
Today as usual I came to office and started my work. As I am in development have to write a code and then run it on the server.But today when I started my server I started Wondering why Java classes direct program messages to the system console, but error messages to the file (log files)?
I tried finding out solution for the same and after struggle of an hour I found the solution for the same. So I thought I will share this with you all and If I am wrong please Correct me .
Here is the Solution:
The class System has a variable out that represents the standard output, and the variable err that represent the standard error device. By default, they both point at the system console. This is how the standard output could be re-directed:
Stream st = new Stream (new FileOutputStream("output.txt"));
System.setOut(st);
And error redirect to the file.
System.setErr(st);
World of tricky Core Java Q and A Covering Object Oriented Analysis and Design, JVM Internals,Java Language Fundamentals,Datatypes,Keywords,Operators and Assignments,Identifies,Declarations and Modifiers, Conversion,Casting and Promotion, Flow control,Assertions, Exception Handling and Garbage Collection,Objects and Classes), Basic Packages and their classes,JDBC,JFC Swing,Java Server Pages (JSP), Servlets,EJB,JMS,JNDI etc and Open source technologies like Struts,Hibernate,Spring etc
Search This Blog
Friday, June 16, 2006
why Java classes direct program messages to the system console, but error messages to the file??
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment