tags:

views:

281

answers:

0

I am trying to switch System.out on a button action, which works but the logger is still writing to the old PrintStream.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

private final static Logger logger = LoggerFactory.getLogger(ActionButtons.class);

PrintStream mStartingOut = System.out;

public void switchOut() {
    if (System.out == mOut.getPrintStream()) System.setOut(mStartingOut); 
    else System.setOut(mOut.getPrintStream());
}

method switchOut() works, but the Logger does not start printing to the new System.Out unless I open up log4j.properties and resave the file to force a resetting of its properties. I cannot find a way to do this via a method call to have slf4j logger reset itself.

Thanks for your help.