I am working on a java project where I have created a SOAP service. What I have a problem with is when I want to create a file from the service class, while communicating with a client, it gets created on my Desktop. I want it to be created inside my project folder.
Here is a part of my code which creates the file:
private static Logger LOGGER = Logger.getLogger(AttractionSetup.class.getName());
static{
try {
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss");
String date = dateFormat.format(new Date());
FileHandler handler = new FileHandler(File.separator + date + ".log", true);
LOGGER.addHandler(handler);
SimpleFormatter formatter = new SimpleFormatter();
handler.setFormatter(formatter);
} catch(IOException ex) {
ex.printStackTrace();
}
}
I need this file for logging exceptions and errors, so it would make much more sense if it was inside the project folder. If someone could explain why it goes to the Desktop it would be really appreciated.