I got the following class to create and manage a Logger
. Whenever across the code and program execution, calls to static getLogger()
catch blocks are used to log.
public class Log {
private static final Logger logger = Logger.getLogger("MyLog");
public static void iniciarLog() throws IOException {
FileHandler fh;
try {
// fh = new FileHandler(System.getProperty("user.home")+System.getProperty("file.separator")+"TorrentDownloader.log");
fh = new FileHandler("%h/TorrentDownloader.log");
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
logger.info("Se inició el log");
} catch (SecurityException | IOException e) {
logger.severe("Error al crear el log");
}
}
public static Logger getLogger() {
return logger;
}
}
However, how can I append to such logging file? All examples I've seen change a lot this implementation which I like as it's clear, brief and simple.
count
parameter? – Rosenblatt