Lines Matching refs:Logger
42 * A Logger object is used to log messages for a specific
44 * using a hierarchical dot-separated namespace. Logger names
48 * "anonymous" Loggers that are not stored in the Logger namespace.
50 * Logger objects may be obtained by calls on one of the getLogger
51 * factory methods. These will either create a new Logger or
52 * return a suitable existing Logger. It is important to note that
53 * the Logger returned by one of the {@code getLogger} factory methods
55 * Logger is not kept.
61 * Each Logger keeps track of a "parent" Logger, which is its
62 * nearest existing ancestor in the Logger namespace.
64 * Each Logger has a "Level" associated with it. This reflects
65 * a minimum Level that this logger cares about. If a Logger's
73 * by calls on the Logger.setLevel method. If a logger's level is
78 * On each logging call the Logger initially performs a cheap
83 * After passing this initial (cheap) test, the Logger will allocate
90 * Each Logger may have a ResourceBundle name associated with it.
92 * If a Logger does not have its own ResourceBundle name, then
106 * When mapping ResourceBundle names to ResourceBundles, the Logger
109 * transition feature in the initial implementation, if the Logger is
111 * SystemClassLoader the Logger will also search up the class stack
157 * All methods on Logger are multi-thread safe.
161 * the namespace. Therefore, any subclasses of Logger (unless they
163 * take care to obtain a Logger instance from the LogManager class and
174 public class Logger {
195 private volatile Logger parent; // our nearest parent.
209 * Return global logger object with the name Logger.GLOBAL_LOGGER_NAME.
214 public static final Logger getGlobal() {
219 * The "global" Logger object is provided as a convenience to developers
222 * in products) should create and use their own Logger objects,
224 * suitable per-Logger granularity. Developers also need to keep a
225 * strong reference to their Logger objects to prevent them from
229 * The field must be initialized by the Logger class initialization
233 * <code>Logger.getGlobal()</code>.
235 * <code>Logger.getGlobal()</code> is not available use the call
236 * <code>Logger.getLogger(Logger.GLOBAL_LOGGER_NAME)</code>
237 * or <code>Logger.getLogger("global")</code>.
240 public static final Logger global = new Logger(GLOBAL_LOGGER_NAME);
259 protected Logger(String name, String resourceBundleName) {
263 Logger(String name, String resourceBundleName, Class<?> caller) {
285 // This constructor is used only to create the global Logger.
287 // and Logger static initializers causing deadlocks.
288 private Logger(String name) {
295 // initialization of the global Logger.
303 // Complete initialization of the global Logger.
311 // (see 7054233), we need to determine if Logger.getLogger is to add
335 private static Logger demandLogger(String name, String resourceBundleName, Class<?> caller) {
344 // ends up calling new Logger(name, resourceBundleName, caller)
359 * created Logger. It is important to understand that a previously
360 * created Logger with the given name may be garbage collected at any
361 * time if there is no strong reference to the Logger. In particular,
363 * {@code getLogger("MyLogger").log(...)} may use different Logger
365 * Logger named "MyLogger" elsewhere in the program.
372 * @return a suitable Logger
377 // adding a new Logger object is handled by LogManager.addLogger().
379 public static Logger getLogger(String name) {
404 * created Logger. It is important to understand that a previously
405 * created Logger with the given name may be garbage collected at any
406 * time if there is no strong reference to the Logger. In particular,
408 * {@code getLogger("MyLogger", ...).log(...)} may use different Logger
410 * Logger named "MyLogger" elsewhere in the program.
412 * If the named Logger already exists and does not yet have a
414 * name is used. If the named Logger already exists and has
426 * @return a suitable Logger
429 * @throws IllegalArgumentException if the Logger already exists and uses
435 // adding a new Logger object is handled by LogManager.addLogger().
437 public static Logger getLogger(String name, String resourceBundleName) {
439 Logger result = demandLogger(name, resourceBundleName, callerClass);
442 // We haven't set a bundle name yet on the Logger, so it's ok to proceed.
445 // above found a previously created Logger. This can happen, for
446 // example, if Logger.getLogger(name) is called and subsequently
447 // Logger.getLogger(name, resourceBundleName) is called. In this case
454 // We already had a bundle name on the Logger and we're trying
465 static Logger getPlatformLogger(String name) {
470 Logger result = manager.demandSystemLogger(name, SYSTEM_LOGGER_RB_NAME);
475 * Create an anonymous Logger. The newly created Logger is not
480 * Because the resulting Logger is anonymous it can be kept private
483 * the control state of the Logger. For example an applet can do
484 * a setLevel or an addHandler on an anonymous Logger.
492 * @return a newly created private Logger
494 public static Logger getAnonymousLogger() {
499 * Create an anonymous Logger. The newly created Logger is not
504 * Because the resulting Logger is anonymous it can be kept private
507 * the control state of the Logger. For example an applet can do
508 * a setLevel or an addHandler on an anonymous Logger.
518 * @return a newly created private Logger
524 // adding a new anonymous Logger object is handled by doSetParent().
526 public static Logger getAnonymousLogger(String resourceBundleName) {
530 Logger result = new Logger(null, resourceBundleName,
533 Logger root = manager.getLogger("");
541 * the result is null, then the Logger will use a resource
552 * logger. Note that if the result is null, then the Logger
562 * Set a filter to control output on this Logger.
564 * After passing the initial "level" check, the Logger will
578 * Get the current filter for this Logger.
607 Logger logger = this;
1266 * Get the log Level that has been specified for this Logger.
1270 * @return this Logger's level
1303 * Typically the root Logger is configured with a set of Handlers
1345 * to its parent Logger. This means that any LogRecords will
1525 * Return the parent for this Logger.
1528 * Thus if a Logger is called "a.b.c.d", and a Logger called "a.b"
1530 * getParent on the Logger "a.b.c.d" will return the Logger "a.b".
1532 * The result will be null if it is called on the root Logger
1535 * @return nearest existing parent Logger
1537 public Logger getParent() {
1547 * Set the parent for this Logger. This method is used by
1548 * the LogManager to update a Logger when the namespace changes.
1556 public void setParent(Logger parent) {
1565 // Logger onto a parent logger.
1566 private void doSetParent(Logger newParent) {
1579 Logger kid = ref.get();
1600 ref.setParentRef(new WeakReference<Logger>(parent));
1611 // Remove the weak reference for the specified child Logger from the
1657 Logger kid = ref.get();
1667 // resource bundle name for this Logger.
1670 Logger target = this;