Jannis Alexakis Jannis Alexakis - 1 year ago 98
Java Question

Append java console to file

I use the following lines to redirect my console output to a file :

PrintStream stream = new PrintStream("console.log");

Now the file is overwritten with every start of the application, thus losing all previous entries, but i´d like it to append every session to a persistent console logfile. Is it possible ?

Answer Source

This should work:

PrintStream stream = new PrintStream(new FileOutputStream("console.log", true));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download