I tried to enable simple logging for my TCP Server. For this purpose I thought that java.util.logging
would do its job fine.
Here is the code that I use to configure my log file:
System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT] [%4$-7s] [%3s] %5$s %n");
try {
FileHandler fileHandler = new FileHandler(System.getProperty("user.dir") +
"/log/RemasteredServer_%u.log", false);
fileHandler.setFormatter(new SimpleFormatter());
Logger.getGlobal().addHandler(fileHandler);
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
logger = Logger.getLogger(ServerMain.class.getName());
When I try to run this I get the following exception:
java.nio.file.NoSuchFileException: C:\Users\samue\log\RemasteredServer_0.log.lck
I already tried different patterns but none of them worked. Thanks for help!
Edit: I wouldn't know why this should be a problem but I use gradle to build and run the server