I have a class generating error output that I'd like to output using Logger. I'm a bit perplexed at how I do this. I have something like this:
public static void main(String[] args) throws Exception {
ClassA foo = new ClassA();
Logger logger = Logger.getLogger(ClassA.class.getName());
FileHandler logFile = new FileHandler("LogToFile2.txt");
logFile.setFormatter(new SimpleFormatter());
logger.addHandler(logFile);
logger.info("A message logged to the file");
foo.bar();
}
It outputs "A message logged to the file", but the rest of the INFO stderr I receive from bar() is not captured.