Search code examples
javaloggingfilehandler

Filehandler create file in directory


How to create log file in an existing directory ?..I have tried out this code:

String fileName = "/log/ABC.log";
FileHandler fileHandler = new FileHandler(fileName, true);

But it is not working.Here log is the directory...


Solution

  • You should take a look at the Logger class which is part of Java (since version 1.4). The FileHandler class is part of the logging package and it relies on the Logger class to actually log the errors to the FileHandler object you create.