import java.io.*; import java.util.logging.*; public class LimitLogFile{ public static void main(String[] args) { try{ Logger log = Logger.getLogger("RoseIndia.Net"); BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter file name which has '.log' extension"); String str = buf.readLine(); File file = new File(str + ".txt"); if(file.exists()) { int limit = 10; FileHandler hand = new FileHandler(str + ".txt", limit,1); System.out.println("Operation successfully."); log.addHandler(hand); } else{ System.out.println("File not found!"); } } catch (IOException e){} } }