In this article, we will see how to use logger Class and logging into file in Java.
In earlier article, we covered that Java got a logger API with various features that we can log application logs. java.util.logging.Logger class is used to log application messages in java logging API. There are different levels for logger, we will see them in detail.
In this part, we will direct our logs into file this time rather console. We use FileHandler class in java to handle file operations.
Lets see it in the code.
Logger log1 = logger.getlogger(...
Lets see it in a java example.
In above example, we printed logs into a file in INFO level.