1 23 24 package com.sun.enterprise.tools.upgrade.logging; 25 26 import java.io.*; 27 import java.util.logging.*; 28 import com.sun.enterprise.tools.upgrade.common.*; 29 30 35 36 public class LogService { 37 38 public static final String UPGRADE_LOGGER="com.sun.enterprise.tools.upgrade"; 39 public static final String UPGRADE_CLI_LOGGER="com.sun.enterprise.tools.upgrade.cli"; 40 public static final String UPGRADE_CERTCONVERSION_LOGGER="com.sun.enterprise.tools.upgrade.certconversion"; 41 private static LogFormatter formatter; 42 private static FileHandler loghandler; 43 44 public static void initialize(String fileName) throws IOException{ 45 LogManager.getLogManager().reset(); 46 formatter = new LogFormatter(); 47 boolean append = true; 48 int limit = 1000000; 49 loghandler = new FileHandler(fileName,limit,1,append); 50 loghandler.setLevel( Level.ALL ); 51 loghandler.setFormatter(formatter); 52 } 53 54 public static Logger getLogger(String name) { 55 Logger logger = Logger.getLogger(name); 56 Handler[] h = logger.getHandlers(); 60 for (int i = 0; i < h.length; i++) { 61 logger.removeHandler(h[i]); 62 } 63 logger.addHandler(loghandler); 64 return logger; 65 } 66 67 public static void addLogMessageListener(LogMessageListener listener){ 68 formatter.addLogMessageListener(listener); 69 } 70 71 public static void removeLogMessageListener(LogMessageListener listener){ 72 formatter.removeLogMessageListener(listener); 73 } 74 75 } 76 77 | Popular Tags |