/** * Override to return a {@link DispatchingLogger} instead of a simple logger {@inheritDoc} * * @return a {@link DispatchingLogger} */ @Override protected Logger newInstance(LoggerContext ctx, final String name, final MessageFactory messageFactory) { return new DispatchingLogger(super.newInstance(ctx, name, messageFactory), ownerClassLoaderHash, this, contextSelector, messageFactory) { // force the name due to log4j2's cyclic constructor dependencies // aren't a friend of the wrapper pattern @Override public String getName() { return name; } }; }
/** * Override to return a {@link DispatchingLogger} instead of a simple logger {@inheritDoc} * * @return a {@link DispatchingLogger} */ @Override protected Logger newInstance(LoggerContext ctx, final String name, final MessageFactory messageFactory) { return new DispatchingLogger(super.newInstance(ctx, name, messageFactory), ownerClassLoaderHash, this, contextSelector, messageFactory) { // force the name due to log4j2's cyclic constructor dependencies // aren't a friend of the wrapper pattern @Override public String getName() { return name; } }; }
/** * Override to return a {@link DispatchingLogger} * instead of a simple logger * {@inheritDoc} * * @return a {@link DispatchingLogger} */ @Override protected Logger newInstance(LoggerContext ctx, final String name, final MessageFactory messageFactory) { return new DispatchingLogger(super.newInstance(ctx, name, messageFactory), ownerClassLoaderHash, this, contextSelector, messageFactory) { // force the name due to log4j2's cyclic constructor dependencies // aren't a friend of the wrapper pattern @Override public String getName() { return name; } }; }
/** * Obtains a Logger from the Context. * * @param name The name of the Logger to return. * @param messageFactory The message factory is used only when creating a logger, subsequent use does not change the * logger but will log a warning if mismatched. * @return The Logger. */ @Override public Logger getLogger(final String name, final MessageFactory messageFactory) { // Note: This is the only method where we add entries to the 'loggerRegistry' ivar. Logger logger = loggerRegistry.getLogger(name, messageFactory); if (logger != null) { AbstractLogger.checkMessageFactory(logger, messageFactory); return logger; } logger = newInstance(this, name, messageFactory); loggerRegistry.putIfAbsent(name, messageFactory, logger); return loggerRegistry.getLogger(name, messageFactory); }