1 29 30 package com.caucho.log; 31 32 import com.caucho.config.ConfigException; 33 import com.caucho.util.L10N; 34 35 import javax.annotation.PostConstruct; 36 import java.util.logging.Level ; 37 import java.util.logging.Logger ; 38 39 42 public class LoggerConfig { 43 private static final L10N L = new L10N(LoggerConfig.class); 44 45 private Logger _logger; 46 private Level _level; 47 private Boolean _useParentHandlers; 48 49 52 public void setName(String name) 53 { 54 _logger = Logger.getLogger(name); 55 } 56 57 60 public void setUseParentHandlers(boolean useParentHandlers) 61 { 62 _useParentHandlers = new Boolean (useParentHandlers); 63 } 64 65 68 public void setLevel(String level) 69 throws ConfigException 70 { 71 if (level.equals("off")) 72 _level = Level.OFF; 73 else if (level.equals("severe")) 74 _level = Level.SEVERE; 75 else if (level.equals("warning")) 76 _level = Level.WARNING; 77 else if (level.equals("info")) 78 _level = Level.INFO; 79 else if (level.equals("config")) 80 _level = Level.CONFIG; 81 else if (level.equals("fine")) 82 _level = Level.FINE; 83 else if (level.equals("finer")) 84 _level = Level.FINER; 85 else if (level.equals("finest")) 86 _level = Level.FINEST; 87 else if (level.equals("all")) 88 _level = Level.ALL; 89 else 90 throw new ConfigException(L.l("`{0}' is an unknown log level. Log levels are:\noff - disable logging\nsevere - severe errors only\nwarning - warnings\ninfo - information\nconfig - configuration\nfine - fine debugging\nfiner - finer debugging\nfinest - finest debugging\nall - all debugging", level)); 91 } 92 93 96 @PostConstruct 97 public void init() 98 { 99 if (_level != null) 100 _logger.setLevel(_level); 101 102 if (_useParentHandlers != null) 103 _logger.setUseParentHandlers(_useParentHandlers.booleanValue()); 104 } 105 } 106 | Popular Tags |