At first, I thought it looked like a bridge design pattern. Upon further
comparison, it doesn't really fit that pattern (nor does it fit any other
common design patterns that I can see). It's rather neat, actually.
Essentially, a Configuration is tied to a LoggerContext. The LoggerContext
produces Loggers, and those Loggers get paired to a Configuration through
the LoggerConfig object. When you call a method on the Logger object, it
will pass along the log event information to its current LoggerConfig. That
LoggerConfig is where appenders, filters, etc., are mostly all located, so
the configured logger is really used at that point.
Thus, when you reconfigure, all the Loggers will still reference the old
configuration still, but each one gets updated and switched over to the new
config atomically. No log messages get lost during the configuration
parsing and construction of the new LoggerConfig objects (and any other
plugin objects relevant to the new config).
I hope that wasn't too in-depth!
On 20 April 2014 06:19, Ralph Goers rgo...@apache.org wrote:
Unlike Log4j 1 and Logback, Log4j 2 separates the configuration from the
actual Logger objects. When a reconfiguration occurs a new Configuration
is created. Once it is completed each Logger is modified to reference a
LoggerConfig in the new Configuration. So for a small amount of time some
Loggers may point to the old Configuration while some point to the new
Configuration, but it will never be the case that a Logger is us configured.
Ralph
On Apr 20, 2014, at 12:18 AM, huang huangyu...@163.com wrote:
Hi all,
I am learning the source code of log4j 2.I want to know how
log4j 2 can reload its configuration without losing log events while
reconfiguration is taking place..How can it make sure it don't lose log
events while reload its configuration.
Thanks.
With regards.
-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org
--
Matt Sicker boa...@gmail.com