private String getStringProperty(String key, String defaultValue) { String property = manager.getProperty(key); return property == null ? defaultValue : property; }
private String getProperty(String propertyName) { return manager.getProperty(className + "." + propertyName); } }
private int getIntProperty(String key, int defaultValue) { String property = manager.getProperty(key); int result = defaultValue; if (property != null) { try { result = Integer.parseInt(property); } catch (Exception e) { // ignore } } return result; }
public static String getFileHandlerPattern() { return LogManager.getLogManager().getProperty("java.util.logging.FileHandler.pattern"); }
public static String getFileHandlerLogPath() { return loggerFile != null ? loggerFile : LogManager.getLogManager().getProperty("java.util.logging.FileHandler.pattern"); }
private static int loggerIntProperty(String name, int def) { String val = LogManager.getLogManager().getProperty(name); if (val == null) { return def; } try { return Integer.parseInt(val); } catch (NumberFormatException e) { return def; } }
private boolean getBooleanProperty(String key, boolean defaultValue) { String property = manager.getProperty(key); if (property == null) { return defaultValue; } boolean result = defaultValue; if ("true".equalsIgnoreCase(property)) { result = true; } else if ("false".equalsIgnoreCase(property)) { result = false; } return result; }
/** * Returns integer property from logging configuration. * * @param name Property name. * @param dfltVal Default value. * @return Parsed property value if it is set and valid or default value otherwise. */ private int getIntProperty(String name, int dfltVal) { String val = manager.getProperty(name); if (val == null) return dfltVal; try { return Integer.parseInt(val.trim()); } catch (Exception ex) { ex.printStackTrace(); return dfltVal; } }
/** * Constructs a {@code SocketHandler} object using the properties read by * the log manager, including the host name and port number. Default * formatting uses the XMLFormatter class and level is set to ALL. * * @throws IOException * if failed to connect to the specified host and port. * @throws IllegalArgumentException * if the host name or port number is illegal. */ public SocketHandler() throws IOException { super(DEFAULT_LEVEL, null, DEFAULT_FORMATTER, null); initSocket(LogManager.getLogManager().getProperty( "java.util.logging.SocketHandler.host"), LogManager .getLogManager().getProperty( "java.util.logging.SocketHandler.port")); }
/** * Returns boolean property from logging configuration. * * @param name Property name. * @param dfltVal Default value. * @return Parsed property value if it is set and valid or default value otherwise. */ @SuppressWarnings("SimplifiableIfStatement") private boolean getBooleanProperty(String name, boolean dfltVal) { String val = manager.getProperty(name); if (val == null) return dfltVal; val = val.toLowerCase(); if ("true".equals(val) || "1".equals(val)) return true; if ("false".equals(val) || "0".equals(val)) return false; return dfltVal; }
String levelProperty = manager.getProperty(name + ".level"); if (levelProperty != null) { try { String handlersProperty = manager.getProperty(handlersPropertyName); if (handlersProperty != null) { for (String handlerName : handlersProperty.split(",|\\s")) { String level = manager.getProperty(handlerName + ".level"); if (level != null) { handler.setLevel(Level.parse(level));
String className = this.getClass().getName(); final String targetName = manager.getProperty(className + ".target"); try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); String sizeString = manager.getProperty(className + ".size"); if (sizeString != null) { try { String pushName = manager.getProperty(className + ".push"); if (pushName != null) { try {
setParent(logger, parent); break; } else if (getProperty(parentName + ".level") != null || getProperty(parentName + ".handlers") != null) { parent = Logger.getLogger(parentName); setParent(logger, parent);
return; String formatter = LogManager.getLogManager().getProperty("java.util.logging.FileHandler.formatter"); newFileHandler.setLevel(fileHandler.getLevel()); try {
String formatter = LogManager.getLogManager().getProperty("java.util.logging.FileHandler.formatter"); try { fh.setFormatter((Formatter) Class.forName(formatter).getDeclaredConstructor().newInstance());
final String filterName = manager.getProperty(prefix + ".filter"); if (filterName != null) { try { String levelName = manager.getProperty(prefix + ".level"); if (levelName != null) { try { final String formatterName = manager.getProperty(prefix + ".formatter"); if (formatterName != null) { try { final String encodingName = manager.getProperty(prefix + ".encoding"); try { internalSetEncoding(encodingName);
String ptrn = manager.getProperty(clsName + ".pattern");
private String getProperty(String name, String defaultValue) { String value = LogManager.getLogManager().getProperty(name); if (value == null) { value = defaultValue; } else { value = value.trim(); } return value; }
public static void readJavaUtilLoggingConfigFromClasspath() { InputStream inputStream = ReflectUtil.getResourceAsStream("logging.properties"); try { if (inputStream != null) { LogManager.getLogManager().readConfiguration(inputStream); String redirectCommons = LogManager.getLogManager().getProperty("redirect.commons.logging"); if ((redirectCommons != null) && (!redirectCommons.equalsIgnoreCase("false"))) { System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger"); } } } catch (Exception e) { throw new PvmException("couldn't initialize logging properly", e); } finally { IoUtil.closeSilently(inputStream); } }
public static void readJavaUtilLoggingConfigFromClasspath() { InputStream inputStream = ReflectUtil.getResourceAsStream("logging.properties"); try { if (inputStream != null) { LogManager.getLogManager().readConfiguration(inputStream); String redirectCommons = LogManager.getLogManager().getProperty("redirect.commons.logging"); if ((redirectCommons != null) && (!redirectCommons.equalsIgnoreCase("false"))) { System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger"); } } } catch (Exception e) { throw new PvmException("couldn't initialize logging properly", e); } finally { IoUtil.closeSilently(inputStream); } }