1 23 package com.sun.enterprise.server.logging; 24 25 import java.io.InputStream ; 26 import java.io.IOException ; 27 28 29 import java.util.ArrayList ; 30 import java.util.List ; 31 import java.util.Iterator ; 32 import java.util.Enumeration ; 33 import java.util.logging.LogManager ; 34 import java.util.logging.Logger ; 35 import java.util.logging.Level ; 36 37 import com.sun.logging.LogDomains; 38 39 import com.sun.enterprise.util.logging.IASLevel; 40 41 42 53 public abstract class BaseLogManager extends LogManager { 54 55 private boolean _configurationRead = false; 62 private List _unInitializedLoggers = new ArrayList (); 63 64 private Boolean mogLoggerCreated = false; 65 66 protected static Logger _logger = null; 69 70 static { 75 IASLevel.ALERT.getName(); 76 } 77 78 protected BaseLogManager() { 79 super(); 80 } 81 82 public String getLoggerResourceBundleName(String loggerName) { 85 86 String result = loggerName + "." + LogDomains.RESOURCE_BUNDLE; 87 88 return result.replaceFirst(LogDomains.DOMAIN_ROOT, 89 LogDomains.PACKAGE_ROOT); 90 } 91 92 protected abstract void initializeLogger(Logger logger); 93 94 protected void doInitializeLogger(Logger logger) 95 { 96 String loggerName = logger.getName( ); 97 if(! ( ( loggerName.startsWith( "org.apache" ) ) 102 || ( loggerName.startsWith( "com.sun.faces" ) ) 103 || ( loggerName.startsWith( "tomcat" ) ) ) ) 104 { 105 if (logger.getResourceBundleName() == null) { 111 try { 112 Logger newLogger = 113 Logger.getLogger(logger.getName(), 114 getLoggerResourceBundleName(logger.getName())); 115 116 assert(logger == newLogger); 117 } catch (Throwable ex) { 118 } 123 } 124 } 125 126 127 initializeLogger(logger); 129 } 130 131 public void readConfiguration(InputStream ins) 137 throws IOException , SecurityException 138 { 139 super.readConfiguration(ins); 140 synchronized (_unInitializedLoggers) { 141 _configurationRead = true; 142 Iterator iter = _unInitializedLoggers.iterator(); 143 while (iter.hasNext()) { 144 Logger l = (Logger )iter.next(); 145 doInitializeLogger(l); 146 } 147 _unInitializedLoggers.clear(); 148 } 149 } 150 151 public boolean addLogger(Logger logger) { 155 156 String modLoggerName = ModuleToLoggerNameMapper.getMatchedModuleLoggerName(logger.getName()); 157 if (modLoggerName !=null && !modLoggerName.equals(logger.getName())) { 158 Logger.getLogger(modLoggerName); } 160 161 boolean result = super.addLogger(logger); 163 164 if (result) { 166 try { 167 168 if (_logger == null) { 171 _logger = logger; 172 } 173 174 synchronized (_unInitializedLoggers) { 178 if (!_configurationRead) { 179 _unInitializedLoggers.add(logger); 180 return result; 181 } else { 182 doInitializeLogger(logger); 183 } 184 } 185 } catch (Throwable th) { 186 th.printStackTrace(); 187 _logger.log(Level.SEVERE, "addLogger exception ", th); 188 } 189 } 190 191 return result; 192 } 193 } 194 195 | Popular Tags |