Jason and Logger in java
JSON
package main.java;import java.io.DataInputStream;import java.io.IOException;import java.util.Scanner;import java.util.logging.FileHandler;import java.util.logging.Logger;import java.util.logging.SimpleFormatter;public class LoggerDemo { public static void main(String args[]) throws Exception{ Logger logger=Logger.getLogger(LoggerDemo.class.getName()); try (Scanner scanner=new Scanner(System.in)) { int a=scanner.nextInt(); FileHandler fileHandler=new FileHandler("/Users/mohan/IdeaProjects/Logger/Log.log"); FileHandler fileHandler1=new FileHandler("/Users/mohan/IdeaProjects/Logger/Log1.log"); FileHandler fileHandler2=new FileHandler("/Users/mohan/IdeaProjects/Logger/Log2.log"); logger.addHandler(fileHandler); logger.addHandler(fileHandler1); logger.addHandler(fileHandler2); logger.getLevel(); logger.getName(); logger.info("run"); logger.warning("no-error"); SimpleFormatter simpleFormatter=new SimpleFormatter(); fileHandler1.setFormatter(simpleFormatter); } System.out.print("LoggerDemo in main class"); logger.info("run");
}
}
json()---->
JSONObject jsonObject=new JSONObject();jsonObject.put("Samsung",map.get("Samsung"));System.out.println(jsonObject);
Comments
Post a Comment