This section illustrates you how to limit the size of a log file in Java. Log files haven't any boundation at the file creation time but Java provides the facility for limiting the size of a log file with the help of FileHandler. If log records are smaller than limiting log file then spaces are worst but it is larger than some information's to be lost or not mentioning in the log file. See detail information and example:
Descriptions of program:
Program takes a file name that should have '.log' extension. If file exists then the capacity of log file is limited or bounded and shows a message "Operation successfully" otherwise it shows message "File not found!" and no any action executed.
Descriptions of code:
FileHandler(String file_name, int limit, int no_file):
This is the constructor of Logging class which is used for declaring a file handler for writing to the set of files. It takes following arguments:
String file_name: File name which has to be written
int limit: The maximum size of file
int no_file: Number of file that has been used by user.
Here is the code of program:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.