logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1172052 [1/2] - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core: ./ src/main/java/org/apache/logging/log4j/core/ src/main/java/org/apache/logging/log4j/core/config/ src/main/java/org/apache/logging/log4j/core/filter/ ...
Date Sat, 17 Sep 2011 19:15:58 GMT
Author: rgoers
Date: Sat Sep 17 19:15:56 2011
New Revision: 1172052

URL: http://svn.apache.org/viewvc?rev=1172052&view=rev
Log:
Created impl subpackage and moved some classses to it. Implemented ExtendedThrowablePatternConverter and ThrowableProxy. Added Javadoc

Added:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filtering.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
      - copied, changed from r1165682, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jContextFactory.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
      - copied, changed from r1165682, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jLogEvent.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java
      - copied, changed from r1147720, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/ReflectionComparison.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverterTest.java
      - copied, changed from r1147720, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java
Removed:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jContextFactory.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jLogEvent.java
Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/pom.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Filter.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Layout.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationMonitor.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/FileConfigurationMonitor.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineSeparatorPatternConverter.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/resources/META-INF/log4j-provider.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/OutputStreamAppenderTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/RegexFilterTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/ThresholdFilterTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/TimeFilterTest.java

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/pom.xml?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/pom.xml (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/pom.xml Sat Sep 17 19:15:56 2011
@@ -62,7 +62,7 @@
      <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.3.1</version>
+      <version>4.7</version>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Filter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Filter.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Filter.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Filter.java Sat Sep 17 19:15:56 2011
@@ -22,24 +22,82 @@ import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.message.Message;
 
 /**
+ * Interface that must be implemented to allow custom event filtering. It is highly recommended that
+ * applications make use of the Filters provided with this implementation before creating their own.
  *
+ * This interface supports "global" filters (i.e. - all events must pass through them first), attached to
+ * specific loggers and associated with Appenders. It is recommended that, where possible, Filter implementations
+ * create a generic filtering method that can be called from any of the filter methods.
  */
 public interface Filter {
 
+    /**
+     * The result that can returned from a filter method call.
+     */
     public enum Result {
-        ACCEPT, NEUTRAL, DENY
+        /**
+         * The event will be processed without further filtering based on the log Level.
+         */
+        ACCEPT,
+        /**
+         * No decision could be made, further filtering should occur.
+         */
+        NEUTRAL,
+        /**
+         * The event should not be processed.
+         */
+        DENY
     }
 
+    /**
+     * Return the result that should be returned when the filter does not match the event.
+     * @return the Result that should be returned when the filter does not match the event.
+     */
     Result getOnMismatch();
-
+    /**
+     * Return the result that should be returned when the filter matches the event.
+     * @return the Result that should be returned when the filter matches the event.
+     */
     Result getOnMatch();
 
+    /**
+     * Filter an event.
+     * @param logger The Logger.
+     * @param level The event logging Level.
+     * @param marker The Marker for the event or null.
+     * @param msg String text to filter on.
+     * @param params An array of parameters or null.
+     * @return the Result.
+     */
     Result filter(Logger logger, Level level, Marker marker, String msg, Object... params);
 
+    /**
+     * Filter an event.
+     * @param logger The Logger.
+     * @param level The event logging Level.
+     * @param marker The Marker for the event or null.
+     * @param msg Any Object.
+     * @param t A Throwable or null.
+     * @return the Result.
+     */
     Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t);
 
+    /**
+     * Filter an event.
+     * @param logger The Logger.
+     * @param level The event logging Level.
+     * @param marker The Marker for the event or null.
+     * @param msg The Message
+     * @param t A Throwable or null.
+     * @return the Result.
+     */
     Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t);
 
+    /**
+     * Filter an event.
+     * @param event The Event to filter on.
+     * @return the Result.
+     */
     Result filter(LogEvent event);
 
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Layout.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Layout.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Layout.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Layout.java Sat Sep 17 19:15:56 2011
@@ -23,16 +23,9 @@ import java.io.Serializable;
  *  Would introduce an EventEncoder, EventRenderer or something similar for the logging event to byte encoding.
  * (RG) A layout can be configured with a Charset and then Strings can be converted to byte arrays. OTOH, it isn't
  * possible to write byte arrays as character streams.
+ * @param T The Object type that will be returned on the formatAs call.
  */
 public interface Layout<T extends Serializable> {
-    // Note that the line.separator property can be looked up even by
-    // applets.
-    /**
-     * @doubt It is very conceivable that distinct layouts might use distinct line separators.  Should not be on the interface.
-     */
-    public static final String LINE_SEP = System.getProperty("line.separator");
-    public static final int LINE_SEP_LEN = LINE_SEP.length();
-
     /**
      * Formats the event suitable for display.
      * @param event The Logging Event.

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Logger.java Sat Sep 17 19:15:56 2011
@@ -34,21 +34,30 @@ import java.util.Map;
  */
 public class Logger extends AbstractLogger {
 
+    /**
+     * config should be consistent across threads.
+     */
+    protected volatile PrivateConfig config;
+
     private final String name;
 
     private final LoggerContext context;
 
     /**
-     * config should be consistent across threads.
+     * The constructor.
+     * @param context The LoggerContext this Logger is associated with.
+     * @param name The name of the Logger.
      */
-    volatile protected PrivateConfig config;
-
     protected Logger(LoggerContext context, String name) {
         this.context = context;
         this.name = name;
         config = new PrivateConfig(context.getConfiguration(), this);
     }
 
+    /**
+     * Returns the name of the Logger.
+     * @return the name of the Logger.
+     */
     public String getName() {
         return name;
     }
@@ -68,16 +77,28 @@ public class Logger extends AbstractLogg
         return new Logger(context, name);
     }
 
+    /**
+     * Return the LoggerContext this Logger is associated with.
+     * @return the LoggerContext.
+     */
     public LoggerContext getContext() {
         return context;
     }
 
+    /**
+     * This method is not exposed through the public API and is provided primarily for unit testing.
+     * @param level The Level to use on this Logger.
+     */
     public synchronized void setLevel(Level level) {
         if (level != null) {
             config = new PrivateConfig(config, level);
         }
     }
 
+    /**
+     * Return the Level associated with the Logger.
+     * @return the Level associate with the Logger.
+     */
     public Level getLevel() {
         return config.level;
     }
@@ -128,41 +149,78 @@ public class Logger extends AbstractLogg
         return config.filter(level, marker, msg, t);
     }
 
+    /**
+     * This method is not exposed through the public API and is used primarily for unit testing.
+     * @param appender The Appender to add to the Logger.
+     */
     public void addAppender(Appender appender) {
         config.config.addLoggerAppender(this, appender);
     }
 
+    /**
+     * This method is not exposed through the public API and is used primarily for unit testing.
+     * @param appender The Appender to remove from the Logger.
+     */
     public void removeAppender(Appender appender) {
         config.loggerConfig.removeAppender(appender.getName());
     }
 
+    /**
+     * This method is not exposed through the public API and is used primarily for unit testing.
+     * @return A Map containing the Appender's name as the key and the Appender as the value.
+     */
     public Map<String, Appender> getAppenders() {
          return config.loggerConfig.getAppenders();
     }
 
+    /**
+     * This method is not exposed through the public API and is used primarily for unit testing.
+     * @return An Iterator over all the Filters associated with the Logger.
+     */
     public Iterator<Filter> getFilters() {
         return config.loggerConfig.getFilters();
     }
 
+    /**
+     * This method is not exposed through the public API and is used primarily for unit testing.
+     * @return The number of Filters associated with the Logger.
+     */
     public int filterCount() {
         return config.loggerConfig.filterCount();
     }
 
+    /**
+     * This method is not exposed through the public API and is used primarily for unit testing.
+     * @param filter The Filter to add.
+     */
     public void addFilter(Filter filter) {
         config.config.addLoggerFilter(this, filter);
     }
 
+    /**
+     * This method is not exposed through the public API and is present only to support the Log4j 1.2
+     * compatibility bridge.
+     * @return true if the associated LoggerConfig is additive, false otherwise.
+     */
     public boolean isAdditive() {
         return config.loggerConfig.isAdditive();
     }
 
+    /**
+     * This method is not exposed through the public API and is present only to support the Log4j 1.2
+     * compatibility bridge.
+     * @param additive Boolean value to indicate whether the Logger is additive or not.
+     */
     public void setAdditive(boolean additive) {
         config.config.setLoggerAdditive(this, additive);
     }
 
     /**
+     * Associates the Logger with a new Configuration. This method is not exposed through the
+     * public API.
+     *
      * There are two ways that could be used to guarantee all threads are aware of changes to
-     * config. 1. synchronize this method. Accessors don't need to be synchronized as Java wil
+     * config. 1. synchronize this method. Accessors don't need to be synchronized as Java will
      * treat all variables within a synchronized block as volatile. 2. Declare the variable
      * volatile. Option 2 is used here as the performance cost is very low and it does a better
      * job at documenting how it is used.

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java Sat Sep 17 19:15:56 2011
@@ -36,14 +36,26 @@ public class AppenderControl {
 
     private final Appender appender;
 
+    /**
+     * Constructor.
+     * @param appender The target Appender.
+     */
     AppenderControl(Appender appender) {
         this.appender = appender;
     }
 
+    /**
+     * Return the Appender.
+     * @return the Appender.
+     */
     public Appender getAppender() {
         return appender;
     }
 
+    /**
+     * Call the appender.
+     * @param event The event to process.
+     */
     public void callAppender(LogEvent event) {
         if (recursive.get() != null) {
             appender.getHandler().error("Recursive call to appender " + appender.getName());

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/BaseConfiguration.java Sat Sep 17 19:15:56 2011
@@ -45,10 +45,21 @@ import java.util.concurrent.ConcurrentMa
 import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
- *
+ * The Base Configuration. Many configuration implementations will extend this class.
  */
 public class BaseConfiguration extends Filterable implements Configuration {
 
+    protected Node rootNode;
+
+    protected PluginManager pluginManager;
+
+    protected final static Logger logger = StatusLogger.getLogger();
+
+    protected final List<ConfigurationListener> listeners =
+        new CopyOnWriteArrayList<ConfigurationListener>();
+
+    protected ConfigurationMonitor monitor = new DefaultConfigurationMonitor();
+
     private String name;
 
     private ConcurrentMap<String, Appender> appenders = new ConcurrentHashMap<String, Appender>();
@@ -61,22 +72,17 @@ public class BaseConfiguration extends F
 
     private boolean started = false;
 
-    protected Node rootNode;
-
-    protected PluginManager pluginManager;
-
-    protected final static Logger logger = StatusLogger.getLogger();
-
-    protected final List<ConfigurationListener> listeners =
-         new CopyOnWriteArrayList<ConfigurationListener>();
-
-    protected ConfigurationMonitor monitor = new DefaultConfigurationMonitor();
-
+    /**
+     * Constructor.
+     */
     protected BaseConfiguration() {
         pluginManager = new PluginManager("Core");
         rootNode = new Node();
     }
 
+    /**
+     * Initialize the configuration.
+     */
     public void start() {
         pluginManager.collectPlugins();
         setup();
@@ -89,6 +95,9 @@ public class BaseConfiguration extends F
         startFilters();
     }
 
+    /**
+     * Tear down the configuration.
+     */
     public void stop() {
         for (LoggerConfig logger : loggers.values()) {
             logger.clearAppenders();
@@ -147,36 +156,75 @@ public class BaseConfiguration extends F
         return pluginManager;
     }
 
+    /**
+     * Set the name of the configuration.
+     * @param name The name.
+     */
     public void setName(String name) {
         this.name = name;
     }
 
+    /**
+     * Return the name of the configuration.
+     * @return the name of the configuration.
+     */
     public String getName() {
         return name;
     }
 
+    /**
+     * Add a listener for changes on the configuration.
+     * @param listener The ConfigurationListener to add.
+     */
     public void addListener(ConfigurationListener listener) {
         listeners.add(listener);
     }
 
+    /**
+     * Remove a ConfigurationListener.
+     * @param listener The ConfigurationListener to remove.
+     */
     public void removeListener(ConfigurationListener listener) {
         listeners.remove(listener);
     }
 
+    /**
+     * Return the Appender with the specified name.
+     * @param name The name of the Appender.
+     * @return the Appender with the specified name or null if the Appender cannot be located.
+     */
     public Appender getAppender(String name) {
         return appenders.get(name);
     }
 
+    /**
+     * Return a Map containing all the Appenders and their name.
+     * @return A Map containing each Appender's naem and the Appender object.
+     */
     public Map<String, Appender> getAppenders() {
         return appenders;
     }
 
+    /**
+     * Adds an Appender to the configuration.
+     * @param appender The Appender to add.
+     */
     public void addAppender(Appender appender) {
         appenders.put(appender.getName(), appender);
     }
 
-    public void addLoggerAppender(org.apache.logging.log4j.core.Logger logger, Appender appender) {
+    /**
+     * Associates an Appender with a LoggerConfig. This method is synchronized in case a Logger with the
+     * same name is being updated at the same time.
+     *
+     * Note: This method is not used when configuring via configuration. It is primarily used by
+     * unit tests.
+     * @param logger The Logger the Appender will be associated with.
+     * @param appender The Appender.
+     */
+    public synchronized void addLoggerAppender(org.apache.logging.log4j.core.Logger logger, Appender appender) {
         String name = logger.getName();
+        appenders.putIfAbsent(name, appender);
         LoggerConfig lc = getLoggerConfig(name);
         if (lc.getName().equals(name)) {
             lc.addAppender(appender);
@@ -190,8 +238,16 @@ public class BaseConfiguration extends F
             logger.getContext().updateLoggers();
         }
     }
-
-    public void addLoggerFilter(org.apache.logging.log4j.core.Logger logger, Filter filter) {
+    /**
+     * Associates a Filter with a LoggerConfig. This method is synchronized in case a Logger with the
+     * same name is being updated at the same time.
+     *
+     * Note: This method is not used when configuring via configuration. It is primarily used by
+     * unit tests.
+     * @param logger The Logger the Fo;ter will be associated with.
+     * @param filter The Filter.
+     */
+    public synchronized void addLoggerFilter(org.apache.logging.log4j.core.Logger logger, Filter filter) {
         String name = logger.getName();
         LoggerConfig lc = getLoggerConfig(name);
         if (lc.getName().equals(name)) {
@@ -206,8 +262,16 @@ public class BaseConfiguration extends F
             logger.getContext().updateLoggers();
         }
     }
-
-    public void setLoggerAdditive(org.apache.logging.log4j.core.Logger logger, boolean additive) {
+    /**
+     * Marks a LoggerConfig as additive. This method is synchronized in case a Logger with the
+     * same name is being updated at the same time.
+     *
+     * Note: This method is not used when configuring via configuration. It is primarily used by
+     * unit tests.
+     * @param logger The Logger the Appender will be associated with.
+     * @param additive True if the LoggerConfig should be additive, false otherwise.
+     */
+    public synchronized void setLoggerAdditive(org.apache.logging.log4j.core.Logger logger, boolean additive) {
         String name = logger.getName();
         LoggerConfig lc = getLoggerConfig(name);
         if (lc.getName().equals(name)) {
@@ -222,17 +286,28 @@ public class BaseConfiguration extends F
         }
     }
 
-    public void removeAppender(String name) {
+    /**
+     * Remove an Appender. First removes any associations between LoggerContigs and the Appender, removes
+     * the Appender from this appender list and then stops the appender. This method is synchronized in
+     * case an Appender with the same name is being added during the removal.
+     */
+    public synchronized void removeAppender(String name) {
         for (LoggerConfig logger : loggers.values()) {
             logger.removeAppender(name);
         }
         Appender app = appenders.remove(name);
 
-        if (app != null && app instanceof Lifecycle) {
-            ((Lifecycle)app).stop();
+        if (app != null) {
+            app.stop();
         }
     }
 
+    /**
+     * Locates the appropriate LoggerConfig for a Logger name. This will remove tokens from the
+     * package name as necessary or return the root LoggerConfig if no other matches were found.
+     * @param name The Logger name.
+     * @return The located LoggerConfig.
+     */
     public LoggerConfig getLoggerConfig(String name) {
         if (loggers.containsKey(name)) {
             return loggers.get(name);
@@ -247,14 +322,27 @@ public class BaseConfiguration extends F
         return root;
     }
 
+    /**
+     * Returns the root Logger.
+     * @return the root Logger.
+     */
     public LoggerConfig getRootLogger() {
         return root;
     }
 
+    /**
+     * Return a Map of all the LoggerConfigs.
+     * @return a Map with each entry containing the name of the Logger and the LoggerConfig.
+     */
     public Map<String, LoggerConfig> getLoggers() {
         return Collections.unmodifiableMap(loggers);
     }
 
+    /**
+     * Returns the LoggerConfig with the specified name.
+     * @param name The Logger name.
+     * @return The LoggerConfig or null if no match was found.
+     */
     public LoggerConfig getLogger(String name) {
         return loggers.get(name);
     }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java Sat Sep 17 19:15:56 2011
@@ -3,30 +3,37 @@ package org.apache.logging.log4j.core.co
 import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.filter.Filtering;
 
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
 /**
- *
+ * Interface that must be implemented to create a configuration.
  */
-public interface Configuration {
+public interface Configuration extends Filtering {
 
+    /**
+     * Return the configuration name.
+     * @return the name of the configuration.
+     */
     String getName();
 
+    /**
+     * Locates the appropriate LoggerConfig for a Logger name. This will remove tokens from the
+     * package name as necessary or return the root LoggerConfig if no other matches were found.
+     * @param name The Logger name.
+     * @return The located LoggerConfig.
+     */
     LoggerConfig getLoggerConfig(String name);
 
+    /**
+     * Return a Map containing all the Appenders and their name.
+     * @return A Map containing each Appender's naem and the Appender object.
+     */
     Map<String, Appender> getAppenders();
 
-    Iterator<Filter> getFilters();
-
-    void addFilter(Filter filter);
-
-    void removeFilter(Filter filter);
-
-    boolean hasFilters();
-
     Map<String, LoggerConfig> getLoggers();
 
     void addLoggerAppender(Logger logger, Appender appender);

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationMonitor.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationMonitor.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationMonitor.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationMonitor.java Sat Sep 17 19:15:56 2011
@@ -1,9 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
 package org.apache.logging.log4j.core.config;
 
 /**
- *
+ * Interface that must be implemented to provide notification of configuration changes.
  */
 public interface ConfigurationMonitor {
 
+    /**
+     * Called to determine if the configuration has changed.
+     */
     void checkConfiguration();
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java Sat Sep 17 19:15:56 2011
@@ -23,15 +23,27 @@ import org.apache.logging.log4j.core.Log
 import org.apache.logging.log4j.core.appender.ConsoleAppender;
 
 /**
- *
+ * The default configuration. It writes all output to the Console using the default logging level
+ * that is configured by setting the "org.apache.logging.log4j.level" system property or the ERROR
+ * Level if the system property is not specified. Log Events will be printed using the basic
+ * formatting provided by each Message.
  */
 public class DefaultConfiguration extends BaseConfiguration {
 
-    private static final String CONSOLE = "CONSOLE";;
-    private static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
-    private static final String EMPTY_STRING = "";
+    /**
+     * The name of the default configuration.
+     */
     public static final String DEFAULT_NAME = "Default";
+    /**
+     * The System Proerty used to specify the logging level.
+     */
+    public static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
+
+    private static final String EMPTY_STRING = "";
 
+    /**
+     * Constructor to create the default configuration.
+     */
     public DefaultConfiguration() {
 
         setName(DEFAULT_NAME);
@@ -44,6 +56,9 @@ public class DefaultConfiguration extend
         root.setLevel(level);
     }
 
+    /**
+     * Formats the event using the Message's built-in format.
+     */
     public class BasicLayout implements Layout<String> {
         public byte[] format(LogEvent event) {
             return formatAs(event).getBytes();

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/FileConfigurationMonitor.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/FileConfigurationMonitor.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/FileConfigurationMonitor.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/FileConfigurationMonitor.java Sat Sep 17 19:15:56 2011
@@ -20,10 +20,15 @@ import java.io.File;
 import java.util.List;
 
 /**
- *
+ * Configuration monitor that periodically checks the timestamp of the configuration file and calls the
+ * ConfigurationListeners when an update occurs.
  */
 public class FileConfigurationMonitor implements ConfigurationMonitor {
 
+    private static final int MASK = 0x0f;
+
+    private final static int MIN_INTERVAL = 30;
+
     private final File file;
 
     private long lastModified;
@@ -34,21 +39,25 @@ public class FileConfigurationMonitor im
 
     private long nextCheck;
 
-    private final static int MIN_INTERVAL = 30;
-
     private volatile int counter = 0;
-    private static final int MASK = 0x0f;
-    private long start;
 
+    /**
+     * Constructor.
+     * @param file The File to monitor.
+     * @param listeners The List of ConfigurationListeners to notify upon a change.
+     * @param interval The monitor interval in seconds. The minimum interval is 30 seconds.
+     */
     public FileConfigurationMonitor(File file, List<ConfigurationListener> listeners, int interval) {
         this.file = file;
         this.lastModified = file.lastModified();
         this.listeners = listeners;
         this.interval = (interval < MIN_INTERVAL ? MIN_INTERVAL : interval) * 1000;
         this.nextCheck = System.currentTimeMillis() + interval;
-        this.start = System.nanoTime();
     }
 
+    /**
+     * Called to determine if the configuration has changed.
+     */
     public void checkConfiguration() {
         if ((++counter & MASK) == 0) {
             long current = System.currentTimeMillis();

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java Sat Sep 17 19:15:56 2011
@@ -20,7 +20,7 @@ import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Log4jLogEvent;
+import org.apache.logging.log4j.core.impl.Log4jLogEvent;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.LogEventFactory;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
@@ -40,34 +40,37 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
- *
+ * Logger object that is created via configuration.
  */
 @Plugin(name="logger",type="Core", printObject=true)
 public class LoggerConfig extends Filterable implements LogEventFactory {
 
+    private static Logger logger = StatusLogger.getLogger();
+
     private List<String> appenderRefs = new ArrayList<String>();
     private Map<String, AppenderControl> appenders = new ConcurrentHashMap<String, AppenderControl>();
-
     private final String name;
-
     private LogEventFactory logEventFactory;
-
     private Level level;
-
     private boolean additive = true;
-
     private LoggerConfig parent;
-
-    private static Logger logger = StatusLogger.getLogger();
-
     private ConfigurationMonitor monitor = new DefaultConfigurationMonitor();
 
+    /**
+     * Default constructor.
+     */
     public LoggerConfig() {
         this.logEventFactory = this;
         this.level = Level.ERROR;
         this.name = "";
     }
 
+    /**
+     * Constructor that sets the name, level and additive values.
+     * @param name The Logger name.
+     * @param level The Level.
+     * @param additive true if the Logger is additive, false otherwise.
+     */
     public LoggerConfig(String name, Level level, boolean additive) {
         this.logEventFactory = this;
         this.name = name;
@@ -85,30 +88,58 @@ public class LoggerConfig extends Filter
         this.additive = additive;
     }
 
+    /**
+     * Set the ConfigurationMonitor that will detect configuration changes.
+     * @param monitor The ConfigurationMonitor.
+     */
     public void setConfigurationMonitor(ConfigurationMonitor monitor) {
         this.monitor = monitor;
     }
 
+    /**
+     * Return the name of the LoggerConfig.
+     * @return the name of the LoggerConfig.
+     */
     public String getName() {
         return name;
     }
 
+    /**
+     * Set the parent of this LoggerConfig.
+     * @param parent the parent LoggerConfig.
+     */
     public void setParent(LoggerConfig parent) {
         this.parent = parent;
     }
 
+    /**
+     * Return the parent of this LoggerConfig.
+     * @return the LoggerConfig that is the parent of this one.
+     */
     public LoggerConfig getParent() {
         return this.parent;
     }
 
+    /**
+     * Add an Appender to the LoggerConfig.
+     * @param appender The Appender to add.
+     */
     public void addAppender(Appender appender) {
         appenders.put(appender.getName(), new AppenderControl(appender));
     }
 
+    /**
+     * Remove the Appender with the specific name.
+     * @param name The name of the Appender.
+     */
     public void removeAppender(String name) {
         appenders.remove(name);
     }
 
+    /**
+     * Return all Appenders as a Map.
+     * @return a Map with the Appender name as the key and the Appender as the value.
+     */
     public Map<String, Appender> getAppenders() {
         Map<String, Appender> map = new HashMap<String, Appender>();
         for (Map.Entry<String, AppenderControl> entry : appenders.entrySet()) {
@@ -117,43 +148,87 @@ public class LoggerConfig extends Filter
         return map;
     }
 
+    /**
+     * Remove all Appenders.
+     */
     protected void clearAppenders() {
         appenders.clear();
     }
 
+    /**
+     * Return the Appender references.
+     * @return a List of all the Appender names attached to this LoggerConfig.
+     */
     public List<String> getAppenderRefs() {
         return appenderRefs;
     }
 
+    /**
+     * Set the logging Level.
+     * @param level The logging Level.
+     */
     public void setLevel(Level level) {
         this.level = level;
     }
 
+    /**
+     * Return the logging Level.
+     * @return the logging Level.
+     */
     public Level getLevel() {
         return level;
     }
 
+    /**
+     * Return the LogEventFactory.
+     * @return the LogEventFactory.
+     */
     public LogEventFactory getLogEventFactory() {
         return logEventFactory;
     }
 
+    /**
+     * Set the LogEventFactory. Usually the LogEventFactory will be this LoggerConfig.
+     * @param logEventFactory the LogEventFactory.
+     */
     public void setLogEventFactory(LogEventFactory logEventFactory) {
         this.logEventFactory = logEventFactory;
     }
 
+    /**
+     * Return the valid of the additive flag.
+     * @return true if the LoggerConfig is additive, false otherwise.
+     */
     public boolean isAdditive() {
         return additive;
     }
 
+    /**
+     * Set the additive setting.
+     * @param additive true if thee LoggerConfig should be additive, false otherwise.
+     */
     public void setAdditive(boolean additive) {
         this.additive = additive;
     }
 
+    /**
+     * Log an event.
+     * @param loggerName The name of the Logger.
+     * @param marker A Marker or null if none is present.
+     * @param fqcn The fully qualified class name of the caller.
+     * @param level The event Level.
+     * @param data The Message.
+     * @param t A Throwable or null.
+     */
     public void log(String loggerName, Marker marker, String fqcn, Level level, Message data, Throwable t) {
         LogEvent event = logEventFactory.createEvent(loggerName, marker, fqcn, level, data, t);
         log(event);
     }
 
+    /**
+     * Logs an event/
+     * @param event Yhe log event.
+     */
     public void log(LogEvent event) {
         monitor.checkConfiguration();
         if (isFiltered(event)) {
@@ -173,6 +248,16 @@ public class LoggerConfig extends Filter
         }
     }
 
+    /**
+     * Create a log event.
+     * @param loggerName The name of the Logger.
+     * @param marker An optional Marker.
+     * @param fqcn The fully qualified class name of the caller.
+     * @param level The event Level.
+     * @param data The Message.
+     * @param t An optional Throwable.
+     * @return The LogEvent.
+     */
     public LogEvent createEvent(String loggerName, Marker marker, String fqcn, Level level, Message data,
                                 Throwable t) {
         return new Log4jLogEvent(loggerName, marker, fqcn, level, data, t);
@@ -182,6 +267,15 @@ public class LoggerConfig extends Filter
         return name == null || name.length() == 0 ? "root" : name;
     }
 
+    /**
+     * Factory method to create a LoggerConfig.
+     * @param additivity True if additive, false otherwise.
+     * @param loggerLevel The Level to be associated with the Logger.
+     * @param loggerName The name of the Logger.
+     * @param refs An array of Appender names.
+     * @param filters A container for Filters.
+     * @return A new LoggerConfig.
+     */
     @PluginFactory
     public static LoggerConfig createLogger(@PluginAttr("additivity") String additivity,
                                             @PluginAttr("level") String loggerLevel,
@@ -201,6 +295,9 @@ public class LoggerConfig extends Filter
         return new LoggerConfig(name, appenderRefs, filters, level, additive);
     }
 
+    /**
+     * The root Logger.
+     */
     @Plugin(name = "root", type = "Core", printObject=true)
     public static class RootLogger extends LoggerConfig {
 

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filtering.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filtering.java?rev=1172052&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filtering.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/Filtering.java Sat Sep 17 19:15:56 2011
@@ -0,0 +1,46 @@
+package org.apache.logging.log4j.core.filter;
+
+import org.apache.logging.log4j.core.Filter;
+
+import java.util.Iterator;
+
+/**
+ * Interface implemented by Classes that allow filtering to occur.
+ */
+public interface Filtering {
+
+    /**
+     * Adds a new Filter.
+     * @param filter The Filter to add.
+     */
+    void addFilter(Filter filter);
+
+    /**
+     * Removes a Filter.
+     * @param filter The Filter to remove.
+     */
+    void removeFilter(Filter filter);
+
+    /**
+     * Removes all Filters.
+     */
+    void clearFilters();
+
+    /**
+     * Returns an Iterator for all the Filters.
+     * @return an Iterator for all the Filters.
+     */
+    Iterator<Filter> getFilters();
+
+    /**
+     * Determins if any Filters are present.
+     * @return true if any Filters are present, false otherwise.
+     */
+    boolean hasFilters();
+
+    /**
+     * Returns the number of Filters associated with the Object.
+     * @return the number of Filters associated with the Object.
+     */
+    int filterCount();
+}

Copied: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java (from r1165682, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jContextFactory.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jContextFactory.java&r1=1165682&r2=1172052&rev=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jContextFactory.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java Sat Sep 17 19:15:56 2011
@@ -14,8 +14,9 @@
  * See the license for the specific language governing permissions and
  * limitations under the license.
  */
-package org.apache.logging.log4j.core;
+package org.apache.logging.log4j.core.impl;
 
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.helpers.Constants;
 import org.apache.logging.log4j.core.helpers.Loader;
 import org.apache.logging.log4j.core.selector.ClassLoaderContextSelector;

Copied: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java (from r1165682, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jLogEvent.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jLogEvent.java&r1=1165682&r2=1172052&rev=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/Log4jLogEvent.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java Sat Sep 17 19:15:56 2011
@@ -14,11 +14,12 @@
  * See the license for the specific language governing permissions and
  * limitations under the license.
  */
-package org.apache.logging.log4j.core;
+package org.apache.logging.log4j.core.impl;
 
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.ThreadContext;
 import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.message.LoggerNameAwareMessage;
 import org.apache.logging.log4j.message.Message;
 
@@ -30,10 +31,11 @@ import java.util.Map;
 import java.util.Stack;
 
 /**
- *
+ * Implementation of a LogEvent.
  */
 public class Log4jLogEvent implements LogEvent, Serializable {
 
+    private static final long serialVersionUID = -1351367343806656055L;
     private static final String NOT_AVAIL = "?";
     private final String fqcnOfLogger;
     private final Marker marker;
@@ -41,18 +43,40 @@ public class Log4jLogEvent implements Lo
     private final String name;
     private final Message message;
     private final long timestamp;
-    private final Throwable throwable;
+    private final ThrowableProxy throwable;
     private final Map<String, Object> mdc;
     private final Stack<String> ndc;
     private String threadName = null;
     private StackTraceElement location;
 
+    /**
+     * Constructor.
+     * @param loggerName The name of the Logger.
+     * @param marker The Marker or null.
+     * @param fqcn The fully qualified class name of the caller.
+     * @param level The logging Level.
+     * @param message The Message.
+     * @param t A Throwable or null.
+     */
     public Log4jLogEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, Throwable t) {
         this(loggerName, marker, fqcn, level, message, t, ThreadContext.getContext(), ThreadContext.cloneStack(), null,
              null, System.currentTimeMillis());
     }
 
-
+    /**
+     * Constructor.
+     * @param loggerName The name of the Logger.
+     * @param marker The Marker or null.
+     * @param fqcn The fully qualified class name of the caller.
+     * @param level The logging Level.
+     * @param message The Message.
+     * @param t A Throwable or null.
+     * @param mdc The mapped diagnostic context.
+     * @param ndc the nested diagnostic context.
+     * @param threadName The name of the thread.
+     * @param location The locations of the caller.
+     * @param timestamp The timestamp of the event.
+     */
     public Log4jLogEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, Throwable t,
                          Map<String, Object> mdc, Stack<String> ndc, String threadName, StackTraceElement location,
                          long timestamp) {
@@ -61,7 +85,7 @@ public class Log4jLogEvent implements Lo
         this.fqcnOfLogger = fqcn;
         this.level = level;
         this.message = message;
-        this.throwable = t;
+        this.throwable = t == null ? null : new ThrowableProxy(t);
         this.mdc = mdc;
         this.ndc = ndc;
         this.timestamp = timestamp;
@@ -151,6 +175,10 @@ public class Log4jLogEvent implements Lo
         return location;
     }
 
+    /**
+     * Creates a LogEventProxy that can be serialized.
+     * @return a LogEventProxy.
+     */
     protected Object writeReplace() {
         return new LogEventProxy(this);
     }
@@ -169,9 +197,12 @@ public class Log4jLogEvent implements Lo
         return sb.toString();
     }
 
+    /**
+     * Proxy pattern used to serialize the LogEvent.
+     */
     private static class LogEventProxy implements Serializable {
 
-
+        private static final long serialVersionUID = -7139032940312647146L;
         private final String fqcnOfLogger;
         private final Marker marker;
         private final Level level;
@@ -198,6 +229,10 @@ public class Log4jLogEvent implements Lo
             this.threadName = event.getThreadName();
         }
 
+        /**
+         * Return a Log4jLogEvent using the data in the proxy.
+         * @returna Log4jLogEvent.
+         */
         protected Object readResolve() {
             return new Log4jLogEvent(name, marker, fqcnOfLogger, level, message, throwable, mdc, ndc, threadName,
                                      location, timestamp);

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java?rev=1172052&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/StackTracePackageElement.java Sat Sep 17 19:15:56 2011
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.impl;
+
+import java.io.Serializable;
+
+/**
+ * Package data for a StackTraceElement
+ */
+public class StackTracePackageElement implements Serializable {
+
+    private static final long serialVersionUID = -2171069569241280505L;
+
+    private final String location;
+
+    private final String version;
+
+    private final boolean isExact;
+
+    public StackTracePackageElement(String location, String version, boolean exact) {
+        this.location = location;
+        this.version = version;
+        this.isExact = exact;
+    }
+
+    public String getLocation() {
+        return location;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public boolean isExact() {
+        return isExact;
+    }
+
+    public String toString() {
+        String exact = isExact ? "" : "~";
+        return exact + "[" + location + ":" + version + "]";
+    }
+}

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java?rev=1172052&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java Sat Sep 17 19:15:56 2011
@@ -0,0 +1,400 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.impl;
+
+import org.apache.logging.log4j.core.helpers.Loader;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.security.CodeSource;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Wraps a Throwable to add packaging information about each stack trace element.
+ */
+public class ThrowableProxy extends Throwable {
+
+    private static final long serialVersionUID = -2752771578252251910L;
+
+    private static Method getCallerClass;
+
+    private static PrivateSecurityManager securityManager;
+
+    private static final org.apache.logging.log4j.Logger logger = StatusLogger.getLogger();
+
+    private final Throwable throwable;
+    private final ThrowableProxy cause;
+    private int commonElementCount;
+
+    private final StackTracePackageElement[] callerPackageData;
+
+
+    static {
+        setupCallerCheck();
+    }
+
+    /**
+     * Construct the wrapper for the Throwable that includes packaging data.
+     * @param throwable The Throwable to wrap.
+     */
+    public ThrowableProxy(Throwable throwable) {
+        this.throwable = throwable;
+        Map<String, CacheEntry> map = new HashMap<String, CacheEntry>();
+        Deque<Class> stack = getCurrentStack();
+        callerPackageData = resolvePackageData(stack, map, null, throwable.getStackTrace());
+        this.cause = (throwable.getCause() == null) ? null :
+            new ThrowableProxy(throwable, stack, map, throwable.getCause());
+    }
+
+    /**
+     * Constructs the wrapper for a Throwable that is referenced as the cause by another
+     * Throwable.
+     * @param parent The Throwable referencing this Throwable.
+     * @param stack The Class stack.
+     * @param map The cache containing the packaging data.
+     * @param cause The Throwable to wrap.
+     */
+    private ThrowableProxy(Throwable parent, Deque<Class> stack, Map<String, CacheEntry> map, Throwable cause) {
+        this.throwable = cause;
+        callerPackageData = resolvePackageData(stack, map, parent.getStackTrace(), cause.getStackTrace());
+        this.cause = (throwable.getCause() == null) ? null :
+            new ThrowableProxy(parent, stack, map, throwable.getCause());
+    }
+
+
+    @Override
+    public void setStackTrace(StackTraceElement[] stackTraceElements) {
+        throw new UnsupportedOperationException("Cannot set the stack trace on a ThrowableProxy");
+    }
+
+    @Override
+    public String getMessage() {
+        return throwable.getMessage();
+    }
+
+    @Override
+    public String getLocalizedMessage() {
+        return throwable.getLocalizedMessage();
+    }
+
+    @Override
+    public Throwable getCause() {
+        return cause;
+    }
+
+    @Override
+    public Throwable initCause(Throwable throwable) {
+        throw new IllegalStateException("Cannot set the cause on a ThrowableProxy");
+    }
+
+    @Override
+    public String toString() {
+        return throwable.toString();
+    }
+
+    @Override
+    public void printStackTrace() {
+        throwable.printStackTrace();
+    }
+
+    @Override
+    public void printStackTrace(PrintStream printStream) {
+        throwable.printStackTrace(printStream);
+    }
+
+    @Override
+    public void printStackTrace(PrintWriter printWriter) {
+        throwable.printStackTrace(printWriter);
+    }
+
+    @Override
+    public Throwable fillInStackTrace() {
+        return this;
+    }
+
+    @Override
+    public StackTraceElement[] getStackTrace() {
+        return throwable.getStackTrace();
+    }
+
+    public String getExtendedStackTrace() {
+        StringBuilder sb = new StringBuilder(throwable.toString());
+        sb.append("\n");
+        formatElements(sb, 0, throwable.getStackTrace(), callerPackageData);
+        if (cause != null) {
+            formatCause(sb, cause);
+        }
+        return sb.toString();
+    }
+
+    private void formatCause(StringBuilder sb, ThrowableProxy cause) {
+        sb.append("Caused by: ").append(cause).append("\n");
+        formatElements(sb, cause.commonElementCount, cause.getStackTrace(), cause.callerPackageData);
+        if (cause.getCause() != null) {
+            formatCause(sb, cause.cause);
+        }
+    }
+
+    private void formatElements(StringBuilder sb, int commonCount, StackTraceElement[] causedTrace,
+                                StackTracePackageElement[] packageData) {
+        for (int i=0; i < packageData.length; ++i) {
+            sb.append("\tat ");
+            sb.append(causedTrace[i]);
+            sb.append(" ");
+            sb.append(packageData[i]);
+            sb.append("\n");
+        }
+        if (commonCount != 0) {
+            sb.append("\t... ").append(commonCount).append(" more").append("\n");
+        }
+    }
+
+    /**
+     * Initialize the cache by resolving everything in the current stack trace via Reflection.getCallerClass
+     * or via the SecurityManager if either are available. These are the only Classes that can be trusted
+     * to be accurate.
+     * @return A Deque containing the current stack of Class objects.
+     */
+    private Deque<Class> getCurrentStack() {
+        if (getCallerClass != null) {
+            Deque<Class> classes = new ArrayDeque<Class>();
+            int index = 2;
+            Class clazz = getCallerClass(index);
+            while (clazz != null) {
+                classes.add(clazz);
+                clazz = getCallerClass(++index);
+            }
+            return classes;
+        } else if (securityManager != null) {
+            Class[] array = securityManager.getClasses();
+            Deque<Class> classes = new ArrayDeque<Class>(array.length);
+            for (Class clazz : array) {
+                classes.add(clazz);
+            }
+            return classes;
+        }
+        return new ArrayDeque<Class>();
+    }
+
+    /**
+     * Resolve all the stack entries in this stack trace that are not common with the parent.
+     * @param map The cache of CacheEntry objects.
+     * @param rootTrace The first stack trace resolve or null.
+     * @param stackTrace The stack trace being resolved.
+     * @return
+     */
+    private StackTracePackageElement[] resolvePackageData(Deque<Class> stack, Map<String, CacheEntry> map,
+                                                          StackTraceElement[] rootTrace,
+                                                          StackTraceElement[] stackTrace) {
+        int stackLength;
+        if (rootTrace != null) {
+            int rootIndex = rootTrace.length - 1;
+            int stackIndex = stackTrace.length - 1;
+            while (rootIndex >= 0 && stackIndex >= 0 && rootTrace[rootIndex].equals(stackTrace[stackIndex])) {
+                --rootIndex;
+                --stackIndex;
+            }
+            commonElementCount = stackTrace.length - 1 - stackIndex;
+            stackLength = stackIndex + 1;
+        } else {
+            commonElementCount = 0;
+            stackLength = stackTrace.length;
+        }
+        StackTracePackageElement[] packageArray = new StackTracePackageElement[stackLength];
+        Class clazz = stack.peekLast();
+        ClassLoader lastLoader = null;
+        for (int i = stackLength - 1; i >= 0 ; --i) {
+            String className = stackTrace[i].getClassName();
+            // The stack returned from getCurrentStack will be missing entries for  java.lang.reflect.Method.invoke()
+            // and its implementation. The Throwable might also contain stack entries that are no longer
+            // present as those methods have returned.
+            if (className.equals(clazz.getName())) {
+                CacheEntry entry = resolvePackageElement(clazz, true);
+                packageArray[i] = entry.element;
+                lastLoader = entry.loader;
+                stack.removeLast();
+                clazz = stack.peekLast();
+            } else {
+                if (map.containsKey(className)) {
+                    CacheEntry entry = map.get(className);
+                    packageArray[i] = entry.element;
+                    if (entry.loader != null) {
+                        lastLoader = entry.loader;
+                    }
+                } else {
+                    CacheEntry entry = resolvePackageElement(loadClass(lastLoader, className), false);
+                    packageArray[i] = entry.element;
+                    map.put(className, entry);
+                    if (entry.loader != null) {
+                        lastLoader = entry.loader;
+                    }
+                }
+            }
+        }
+        return packageArray;
+    }
+
+
+    /**
+     * Construct the CacheEntry from the Class's information.
+     * @param callerClass The Class.
+     * @param exact True if the class was obtained via Reflection.getCallerClass.
+     * @return The CacheEntry.
+     */
+    private CacheEntry resolvePackageElement(Class callerClass, boolean exact) {
+        String location = "?";
+        String version = "?";
+        ClassLoader lastLoader = null;
+        if (callerClass != null) {
+            try {
+                CodeSource source = callerClass.getProtectionDomain().getCodeSource();
+                if (source != null) {
+                    URL locationURL = source.getLocation();
+                    if (locationURL != null) {
+                        String str = locationURL.toString().replace('\\', '/');
+                        int index = str.lastIndexOf("/");
+                        if (index >= 0 && index == str.length() - 1) {
+                            index = str.lastIndexOf("/", index - 1);
+                            location = str.substring(index + 1);
+                        } else {
+                            location = str.substring(index + 1);
+                        }
+                    }
+                }
+            } catch (Exception ex) {
+                // Ignore the exception.
+            }
+            Package pkg = callerClass.getPackage();
+            if (pkg != null) {
+                String ver = pkg.getImplementationVersion();
+                if (ver != null) {
+                    version = ver;
+                }
+            }
+            lastLoader = callerClass.getClassLoader();
+        }
+        return new CacheEntry(new StackTracePackageElement(location, version, exact), lastLoader);
+    }
+
+    /**
+     * Invoke Reflection.getCallerClass via reflection. This is slightly slower than calling the method
+     * directly but removes any dependency on Sun's JDK being present at compile time. The difference
+     * can be measured by running the ReflectionComparison test.
+     * @param index The index into the stack trace.
+     * @return The Class at the specified stack entry.
+     */
+    private Class getCallerClass(int index) {
+        if (getCallerClass != null) {
+            try {
+                Object[] params = new Object[]{index};
+                return (Class) getCallerClass.invoke(null, params);
+            } catch (Exception ex) {
+                // logger.debug("Unable to determine caller class via Sun Reflection", ex);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Loads classes not located via Reflection.getCallerClass.
+     * @param lastLoader The ClassLoader that loaded the Class that called this Class.
+     * @param className The name of the Class.
+     * @return The Class object for the Class or null if it could not be located.
+     */
+    private Class loadClass(ClassLoader lastLoader, String className) {
+        Class clazz = null;
+        if (lastLoader != null) {
+            try {
+                clazz = lastLoader.loadClass(className);
+                if (clazz != null) {
+                    return clazz;
+                }
+            } catch (Exception ex) {
+                // Ignore exception.
+            }
+        }
+        try {
+            clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+        } catch (ClassNotFoundException e) {
+            try {
+                clazz = Class.forName(className);
+            } catch (ClassNotFoundException e1) {
+                try {
+                    clazz = getClass().getClassLoader().loadClass(className);
+                } catch (ClassNotFoundException e2) {
+                    return null;
+                }
+            }
+        }
+        return clazz;
+    }
+
+    /**
+     * Determine if Reflection.getCallerClass is available.
+     */
+    private static void setupCallerCheck() {
+        try {
+            ClassLoader loader = Loader.getClassLoader();
+            Class clazz = loader.loadClass("sun.reflect.Reflection");
+            Method[] methods = clazz.getMethods();
+            for (Method method : methods) {
+                int modifier = method.getModifiers();
+                if (method.getName().equals("getCallerClass") && Modifier.isStatic(modifier)) {
+                    getCallerClass = method;
+                    return;
+                }
+            }
+        } catch (ClassNotFoundException cnfe) {
+            logger.debug("sun.reflect.Reflection is not installed");
+        }
+
+        try {
+            PrivateSecurityManager mgr = new PrivateSecurityManager();
+            if (mgr.getClasses() != null) {
+                securityManager = mgr;
+            } else {
+                // This shouldn't happen.
+                logger.error("Unable to obtain call stack from security manager");
+            }
+        } catch (Exception ex) {
+            logger.debug("Unable to install security manager", ex);
+        }
+    }
+
+    private class CacheEntry {
+        StackTracePackageElement element;
+        ClassLoader loader;
+
+        public CacheEntry(StackTracePackageElement element, ClassLoader loader) {
+            this.element = element;
+            this.loader = loader;
+        }
+    }
+
+    private static class PrivateSecurityManager extends SecurityManager {
+        public Class[] getClasses() {
+            return getClassContext();
+        }
+    }
+}

Added: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java?rev=1172052&view=auto
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java (added)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/impl/package-info.java Sat Sep 17 19:15:56 2011
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+/**
+ * Log4j 2.0 private implementation classes.
+ */
+package org.apache.logging.log4j.core.impl;
\ No newline at end of file

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/javaee/JNDIContextFilter.java Sat Sep 17 19:15:56 2011
@@ -17,8 +17,8 @@
 package org.apache.logging.log4j.core.javaee;
 
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.impl.Log4jContextFactory;
 import org.apache.logging.log4j.core.selector.ContextSelector;
-import org.apache.logging.log4j.core.Log4jContextFactory;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.selector.NamedContextSelector;
 import org.apache.logging.log4j.spi.LoggerContextFactory;

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/jmx/Log4jManager.java Sat Sep 17 19:15:56 2011
@@ -17,7 +17,7 @@
 package org.apache.logging.log4j.core.jmx;
 
 import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Log4jContextFactory;
+import org.apache.logging.log4j.core.impl.Log4jContextFactory;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.selector.ContextSelector;
 import org.apache.logging.log4j.status.StatusData;

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/layout/HTMLLayout.java Sat Sep 17 19:15:56 2011
@@ -49,6 +49,8 @@ public class HTMLLayout extends Abstract
     // Print no location info by default
     protected final boolean locationInfo;
 
+    private static final String LINE_SEP = System.getProperty("line.separator");
+
     private static final String DEFAULT_TITLE = "Log4J Log Messages";
 
     private static final String DEFAULT_CONTENT_TYPE = "text/html";

Copied: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java (from r1147720, logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java?p2=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java&p1=logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java&r1=1147720&r2=1172052&rev=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverter.java Sat Sep 17 19:15:56 2011
@@ -19,36 +19,30 @@ package org.apache.logging.log4j.core.pa
 
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.impl.ThrowableProxy;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
 
 
 /**
- * Outputs the ThrowableInformation portion of the LoggingiEvent as a full stacktrace
- * unless this converter's option is 'short', where it just outputs the first line of the trace.
+ * Outputs the Throwable portion of the LoggingEvent as a full stacktrace
+ * unless this converter's option is 'short', where it just outputs the first line of the trace, or if
+ * the number of lines to print is explicitly specified.
+ * <p>
+ * The extended stack trace will also include the location of where the class was loaded from and the
+ * version of the jar if available.
  */
-@Plugin(name = "ThrowablePatternConverter", type = "Converter")
-@ConverterKeys({"ex", "throwable"})
-public class ThrowablePatternConverter extends LogEventPatternConverter {
-    /**
-     * If "short", only first line of throwable report will be formatted.
-     */
-    private final String option;
-
+@Plugin(name = "ExtendedThrowablePatternConverter", type = "Converter")
+@ConverterKeys({"xEx", "xThrowable", "xException"})
+public class ExtendedThrowablePatternConverter extends ThrowablePatternConverter {
     /**
      * Private constructor.
      *
      * @param options options, may be null.
      */
-    private ThrowablePatternConverter(final String[] options) {
-        super("Throwable", "throwable");
-
-        if ((options != null) && (options.length > 0)) {
-            option = options[0];
-        } else {
-            option = null;
-        }
+    private ExtendedThrowablePatternConverter(final String[] options) {
+        super("ExtendedThrowable", "throwable", options);
     }
 
     /**
@@ -58,35 +52,34 @@ public class ThrowablePatternConverter e
      *                only the first line of the throwable will be formatted.
      * @return instance of class.
      */
-    public static ThrowablePatternConverter newInstance(
+    public static ExtendedThrowablePatternConverter newInstance(
         final String[] options) {
-        return new ThrowablePatternConverter(options);
+        return new ExtendedThrowablePatternConverter(options);
     }
 
     /**
      * {@inheritDoc}
      */
     public void format(final LogEvent event, final StringBuilder toAppendTo) {
-        Throwable t = event.getThrown();
+        Throwable throwable = event.getThrown();
+        if (throwable != null) {
+            if (!(throwable instanceof ThrowableProxy)) {
+                super.format(event, toAppendTo);
+                return;
+            }
+            ThrowableProxy t = (ThrowableProxy) throwable;
+            String trace = t.getExtendedStackTrace();
+            if (lines > 0) {
+                StringBuilder sb = new StringBuilder();
+                String[] array = trace.split("\n");
+                for (int i = 0; i < lines; ++i) {
+                    sb.append(array[i]).append("\n");
+                }
+                toAppendTo.append(sb.toString());
 
-        if (t != null) {
-            if (option == null || option.equals("full")) {
-                StringWriter w = new StringWriter();
-                t.printStackTrace(new PrintWriter(w));
-                toAppendTo.append(w.toString());
             } else {
-                StackTraceElement[] e = t.getStackTrace();
-                toAppendTo.append(t.toString()).append(" at ").append(e[0].toString());
+                toAppendTo.append(trace);
             }
         }
     }
-
-    /**
-     * This converter obviously handles throwables.
-     *
-     * @return true.
-     */
-    public boolean handlesThrowable() {
-        return true;
-    }
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineSeparatorPatternConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineSeparatorPatternConverter.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineSeparatorPatternConverter.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/LineSeparatorPatternConverter.java Sat Sep 17 19:15:56 2011
@@ -28,6 +28,8 @@ import org.apache.logging.log4j.core.con
 @Plugin(name="LineSeparatorPatternConverter", type="Converter")
 @ConverterKeys({"n"})
 public final class LineSeparatorPatternConverter extends LogEventPatternConverter {
+
+  private static final String LINE_SEP = System.getProperty("line.separator");
   /**
    * Singleton.
    */
@@ -44,7 +46,7 @@ public final class LineSeparatorPatternC
    */
   private LineSeparatorPatternConverter() {
     super("Line Sep", "lineSep");
-    lineSep = Layout.LINE_SEP;
+    lineSep = LINE_SEP;
   }
 
   /**

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java Sat Sep 17 19:15:56 2011
@@ -25,30 +25,47 @@ import java.io.StringWriter;
 
 
 /**
- * Outputs the ThrowableInformation portion of the LoggingiEvent as a full stacktrace
- * unless this converter's option is 'short', where it just outputs the first line of the trace.
+ * Outputs the Throwable portion of the LoggingEvent as a full stacktrace
+ * unless this converter's option is 'short', where it just outputs the first line of the trace, or if
+ * the number of lines to print is explicitly specified.
  */
 @Plugin(name = "ThrowablePatternConverter", type = "Converter")
-@ConverterKeys({"ex", "throwable"})
+@ConverterKeys({"ex", "throwable", "exception"})
 public class ThrowablePatternConverter extends LogEventPatternConverter {
     /**
-     * If "short", only first line of throwable report will be formatted.
+     * If "short", only first line of throwable report will be formatted.<br>
+     * If "full", the whole stack trace will be formatted.<br>
+     * If "numeric" the output will be limited to the specified number of lines.
      */
-    private final String option;
+    protected final String option;
+
+    protected static final String FULL = "full";
+    protected static final String SHORT = "short";
+
+    protected final int lines;
 
     /**
-     * Private constructor.
-     *
+     * Constructor.
+     * @param name Name of converter.
+     * @param style CSS style for output.
      * @param options options, may be null.
      */
-    private ThrowablePatternConverter(final String[] options) {
-        super("Throwable", "throwable");
-
+    protected ThrowablePatternConverter(String name, String style, final String[] options) {
+        super(name, style);
+        int count = 0;
         if ((options != null) && (options.length > 0)) {
             option = options[0];
+            if (option.equalsIgnoreCase(SHORT)) {
+                count = 2;
+            } else if (option.equalsIgnoreCase(FULL)) {
+            } else {
+                count = Integer.parseInt(option);
+            }
+
         } else {
             option = null;
         }
+        lines = count;
     }
 
     /**
@@ -60,7 +77,7 @@ public class ThrowablePatternConverter e
      */
     public static ThrowablePatternConverter newInstance(
         final String[] options) {
-        return new ThrowablePatternConverter(options);
+        return new ThrowablePatternConverter("Throwable", "throwable", options);
     }
 
     /**
@@ -70,13 +87,18 @@ public class ThrowablePatternConverter e
         Throwable t = event.getThrown();
 
         if (t != null) {
-            if (option == null || option.equals("full")) {
-                StringWriter w = new StringWriter();
-                t.printStackTrace(new PrintWriter(w));
-                toAppendTo.append(w.toString());
+            StringWriter w = new StringWriter();
+            t.printStackTrace(new PrintWriter(w));
+            if (lines > 0) {
+                StringBuilder sb = new StringBuilder();
+                String[] array = w.toString().split("\n");
+                for (int i = 0; i < lines; ++i) {
+                    sb.append(array[i]).append("\n");
+                }
+                toAppendTo.append(sb.toString());
+
             } else {
-                StackTraceElement[] e = t.getStackTrace();
-                toAppendTo.append(t.toString()).append(" at ").append(e[0].toString());
+                toAppendTo.append(w.toString());
             }
         }
     }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/resources/META-INF/log4j-provider.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/resources/META-INF/log4j-provider.xml?rev=1172052&r1=1172051&r2=1172052&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/resources/META-INF/log4j-provider.xml (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/resources/META-INF/log4j-provider.xml Sat Sep 17 19:15:56 2011
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
-    <entry key="LoggerContextFactory">org.apache.logging.log4j.core.Log4jContextFactory</entry>
+    <entry key="LoggerContextFactory">org.apache.logging.log4j.core.impl.Log4jContextFactory</entry>
     <entry key="Log4jAPIVersion">1.99.0</entry>
 </properties>
\ No newline at end of file



Mime
View raw message