src/share/classes/java/util/logging/LogManager.java

Print this page




1113         // calling setParent.
1114         AccessController.doPrivileged(new PrivilegedAction<Object>() {
1115             @Override
1116             public Object run() {
1117                 logger.setParent(parent);
1118                 return null;
1119             }});
1120     }
1121 
1122     /**
1123      * Method to find a named logger.
1124      * <p>
1125      * Note that since untrusted code may create loggers with
1126      * arbitrary names this method should not be relied on to
1127      * find Loggers for security sensitive logging.
1128      * It is also important to note that the Logger associated with the
1129      * String {@code name} may be garbage collected at any time if there
1130      * is no strong reference to the Logger. The caller of this method
1131      * must check the return value for null in order to properly handle
1132      * the case where the Logger has been garbage collected.
1133      * <p>
1134      * @param name name of the logger
1135      * @return  matching logger or null if none is found
1136      */
1137     public Logger getLogger(String name) {
1138         return getUserContext().findLogger(name);
1139     }
1140 
1141     /**
1142      * Get an enumeration of known logger names.
1143      * <p>
1144      * Note:  Loggers may be added dynamically as new classes are loaded.
1145      * This method only reports on the loggers that are currently registered.
1146      * It is also important to note that this method only returns the name
1147      * of a Logger, not a strong reference to the Logger itself.
1148      * The returned String does nothing to prevent the Logger from being
1149      * garbage collected. In particular, if the returned name is passed
1150      * to {@code LogManager.getLogger()}, then the caller must check the
1151      * return value from {@code LogManager.getLogger()} for null to properly
1152      * handle the case where the Logger has been garbage collected in the
1153      * time since its name was returned by this method.
1154      * <p>
1155      * @return  enumeration of logger name strings
1156      */
1157     public Enumeration<String> getLoggerNames() {
1158         return getUserContext().getLoggerNames();
1159     }
1160 
1161     /**
1162      * Reinitialize the logging properties and reread the logging configuration.
1163      * <p>
1164      * The same rules are used for locating the configuration properties
1165      * as are used at startup.  So normally the logging properties will
1166      * be re-read from the same file that was used at startup.
1167      * <P>
1168      * Any log level definitions in the new configuration file will be
1169      * applied using Logger.setLevel(), if the target Logger exists.
1170      * <p>
1171      * A PropertyChangeEvent will be fired after the properties are read.
1172      *
1173      * @exception  SecurityException  if a security manager exists and if
1174      *             the caller does not have LoggingPermission("control").




1113         // calling setParent.
1114         AccessController.doPrivileged(new PrivilegedAction<Object>() {
1115             @Override
1116             public Object run() {
1117                 logger.setParent(parent);
1118                 return null;
1119             }});
1120     }
1121 
1122     /**
1123      * Method to find a named logger.
1124      * <p>
1125      * Note that since untrusted code may create loggers with
1126      * arbitrary names this method should not be relied on to
1127      * find Loggers for security sensitive logging.
1128      * It is also important to note that the Logger associated with the
1129      * String {@code name} may be garbage collected at any time if there
1130      * is no strong reference to the Logger. The caller of this method
1131      * must check the return value for null in order to properly handle
1132      * the case where the Logger has been garbage collected.
1133      *
1134      * @param name name of the logger
1135      * @return  matching logger or null if none is found
1136      */
1137     public Logger getLogger(String name) {
1138         return getUserContext().findLogger(name);
1139     }
1140 
1141     /**
1142      * Get an enumeration of known logger names.
1143      * <p>
1144      * Note:  Loggers may be added dynamically as new classes are loaded.
1145      * This method only reports on the loggers that are currently registered.
1146      * It is also important to note that this method only returns the name
1147      * of a Logger, not a strong reference to the Logger itself.
1148      * The returned String does nothing to prevent the Logger from being
1149      * garbage collected. In particular, if the returned name is passed
1150      * to {@code LogManager.getLogger()}, then the caller must check the
1151      * return value from {@code LogManager.getLogger()} for null to properly
1152      * handle the case where the Logger has been garbage collected in the
1153      * time since its name was returned by this method.
1154      *
1155      * @return  enumeration of logger name strings
1156      */
1157     public Enumeration<String> getLoggerNames() {
1158         return getUserContext().getLoggerNames();
1159     }
1160 
1161     /**
1162      * Reinitialize the logging properties and reread the logging configuration.
1163      * <p>
1164      * The same rules are used for locating the configuration properties
1165      * as are used at startup.  So normally the logging properties will
1166      * be re-read from the same file that was used at startup.
1167      * <P>
1168      * Any log level definitions in the new configuration file will be
1169      * applied using Logger.setLevel(), if the target Logger exists.
1170      * <p>
1171      * A PropertyChangeEvent will be fired after the properties are read.
1172      *
1173      * @exception  SecurityException  if a security manager exists and if
1174      *             the caller does not have LoggingPermission("control").