Situation:
Printing to stdout is a major tool for debug at most time for most programmers, I believe. But sometimes, maybe in a daemon or a job in a framework certain framework, there is problem with stdio. The problem is you just can't get the fucking printf work. You see nothing in the log file and get a fucking blind eye, which is quite annoying. Redirecting is one tool you could use.
I guess in daemon process there is kind of conflict in stdout. But haven't got yet into it.
Solution:
Redirect stdout to a file in code.
Implementation:
In Java:
System.setOut(new PrintStream(new File("test.txt")));
System.out.println("Where am i?");
//cat test.txt and see what's there
in C:
freopen("D:\\OUTPUT.txt", "w", stdout);
printf("Where am i?");
Reflection:
From the days I'm fucked by being blind with you program stdout, I know I didn't know printf well.
http://blog.csdn.net/cheetach119/article/details/23339629