I am very new to java and coding so please understand that I am very naive when it comes to this stuff.
I am trying to get Java to write logs to a .txt file. I have been researching this for hours and my brain hurts too much to keep looking. I am hoping you guys can look at this and tell me what is wrong. Below is the code. This is being written on my Mac for the time being but ultimately I will have it run on Windows.
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.Level;
public class WriteLogEntriesToLogFile extends Login {
public WriteLogEntriesToLogFile(String[] args) throws Exception {
boolean append = true;
FileHandler handler = new FileHandler("Test.logon.log.txt");
Logger logger = Logger.getLogger("/Downloads/log.txt");
logger.addHandler(handler);
logger.severe("severe message");
logger.warning("warning message");
logger.info("info message");
logger.config("config message");
logger.fine("fine message");
logger.finer("finer message");
logger.finest("finest message");
}
}
I definitely feel like I am missing something (or a lot of somethings). Any assistance is appreciated!