MyLogger log = new MyLogger();
lg = "Query....................."
log.main(lg);
Library Class
package dcl_payroll;
/**
*
* @author sakib
*/
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class MyLogger {
// public static void main(String[] args) {
public static void main(String s) {
Logger logger = Logger.getLogger("MyLog");
FileHandler fh;
try {
// This block configure the logger with handler and formatter
int limit = 1000000; // 1 Mb
fh = new FileHandler("C:\\temp\\test\\MyLogFile.log", limit,1,true);
// fh = new FileHandler("C:/temp/test/MyLogFile.log");
logger.addHandler(fh);
//logger.setLevel(Level.ALL);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
// the following statement is used to log any messages
logger.info(s);
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// logger.info("Hi How r u?");
}
}
lg = "Query....................."
log.main(lg);
Library Class
package dcl_payroll;
/**
*
* @author sakib
*/
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class MyLogger {
// public static void main(String[] args) {
public static void main(String s) {
Logger logger = Logger.getLogger("MyLog");
FileHandler fh;
try {
// This block configure the logger with handler and formatter
int limit = 1000000; // 1 Mb
fh = new FileHandler("C:\\temp\\test\\MyLogFile.log", limit,1,true);
// fh = new FileHandler("C:/temp/test/MyLogFile.log");
logger.addHandler(fh);
//logger.setLevel(Level.ALL);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
// the following statement is used to log any messages
logger.info(s);
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// logger.info("Hi How r u?");
}
}
No comments:
Post a Comment