You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2011/12/22 08:43:57 UTC
svn commit: r1222082 [1/2] - in
/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers: ./
log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/flume/
log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/
log4j2-core/src...
Author: rgoers
Date: Thu Dec 22 07:43:55 2011
New Revision: 1222082
URL: http://svn.apache.org/viewvc?rev=1222082&view=rev
Log:
Continue fixing checkstyle and PMD errors
Modified:
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/flume/FlumeAvroManager.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicy.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescription.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescriptionImpl.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverFrequency.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategy.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategyBase.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/SizeBasedTriggeringPolicy.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/Action.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ActionBase.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/CompositeAction.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/FileRenameAction.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/GZCompressAction.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ZipCompressAction.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Route.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.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/ConfigurationFactory.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/JSONConfiguration.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfigurationFactory.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PropertiesPlugin.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilter.java
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/filter/MapFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MarkerFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/RegexFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/StructuredDataFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ThresholdFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/TimeFilter.java
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/ValueLevelPair.java
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/checkstyle.xml Thu Dec 22 07:43:55 2011
@@ -124,7 +124,7 @@
</module>
<module name="MethodLength"/>
<module name="ParameterNumber">
- <property name="max" value="10"/>
+ <property name="max" value="15"/>
</module>
@@ -151,7 +151,9 @@
<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
- <module name="AvoidNestedBlocks"/>
+ <module name="AvoidNestedBlocks">
+ <property name="allowInSwitchCase" value="true"/>
+ </module>
<!-- Require empty catch blocks to have at least a comment -->
<module name="EmptyBlock">
<property name="option" value="text"/>
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/flume/FlumeAvroManager.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/appender/flume/FlumeAvroManager.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/flume/FlumeAvroManager.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/flume/FlumeAvroManager.java Thu Dec 22 07:43:55 2011
@@ -199,7 +199,7 @@ public class FlumeAvroManager extends Ab
* Factory data.
*/
private static class FactoryData {
- Agent[] agents;
+ private Agent[] agents;
/**
* Constructor.
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicy.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/appender/rewrite/MapRewritePolicy.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicy.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/MapRewritePolicy.java Thu Dec 22 07:43:55 2011
@@ -36,8 +36,10 @@ import java.util.Map;
*/
@Plugin(name = "MapRewritePolicy", type = "Core", elementType = "rewritePolicy", printObject = true)
public final class MapRewritePolicy implements RewritePolicy {
-
- protected final static Logger LOGGER = StatusLogger.getLogger();
+ /**
+ * Allow subclasses access to the status logger without creating another instance.
+ */
+ protected static final Logger LOGGER = StatusLogger.getLogger();
private final Map<String, String> map;
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.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/appender/rolling/DefaultRolloverStrategy.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java Thu Dec 22 07:43:55 2011
@@ -61,7 +61,9 @@ import java.util.List;
*/
@Plugin(name = "DefaultRolloverStrategy", type = "Core", printObject = true)
public class DefaultRolloverStrategy implements RolloverStrategy {
-
+ /**
+ * Allow subclasses access to the status logger without creating another instance.
+ */
protected static final Logger LOGGER = StatusLogger.getLogger();
private static final int MIN_WINDOW_SIZE = 1;
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.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/appender/rolling/OnStartupTriggeringPolicy.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java Thu Dec 22 07:43:55 2011
@@ -30,13 +30,12 @@ import java.lang.management.ManagementFa
@Plugin(name = "OnStartupTriggeringPolicy", type = "Core", printObject = true)
public class OnStartupTriggeringPolicy implements TriggeringPolicy {
+ private static final long JVM_START_TIME = ManagementFactory.getRuntimeMXBean().getStartTime();
private boolean evaluated = false;
private RollingFileManager manager;
- private static long jvmStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
-
/**
* Provide the RollingFileManager to the policy.
* @param manager The RollingFileManager.
@@ -55,7 +54,7 @@ public class OnStartupTriggeringPolicy i
return false;
}
evaluated = true;
- return manager.getFileTime() < jvmStartTime;
+ return manager.getFileTime() < JVM_START_TIME;
}
@Override
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescription.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/appender/rolling/RolloverDescription.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescription.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescription.java Thu Dec 22 07:43:55 2011
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
package org.apache.logging.log4j.core.appender.rolling;
@@ -51,4 +51,4 @@ public interface RolloverDescription {
* @return action, may be null.
*/
Action getAsynchronous();
-}
\ 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/appender/rolling/RolloverDescriptionImpl.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/appender/rolling/RolloverDescriptionImpl.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescriptionImpl.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverDescriptionImpl.java Thu Dec 22 07:43:55 2011
@@ -100,4 +100,4 @@ public final class RolloverDescriptionIm
public Action getAsynchronous() {
return asynchronous;
}
-}
\ 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/appender/rolling/RolloverFrequency.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/appender/rolling/RolloverFrequency.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverFrequency.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverFrequency.java Thu Dec 22 07:43:55 2011
@@ -17,15 +17,23 @@
package org.apache.logging.log4j.core.appender.rolling;
/**
- *
+ * Enumeration of rollover frequency values.
*/
public enum RolloverFrequency {
+ /** Rollover annually. */
ANNUALLY,
+ /** Rollover monthly. */
MONTHLY,
+ /** Rollover weekly. */
WEEKLY,
+ /** Rollover daily. */
DAILY,
+ /** Rollover every hour. */
HOURLY,
+ /** Rollover every minute. */
EVERY_MINUTE,
+ /** Rollover every second. */
EVERY_SECOND,
+ /** Rollover every millisecond. */
EVERY_MILLISECOND
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategy.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/appender/rolling/RolloverStrategy.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategy.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategy.java Thu Dec 22 07:43:55 2011
@@ -21,13 +21,13 @@ package org.apache.logging.log4j.core.ap
*
*/
public interface RolloverStrategy {
- /**
- * Prepare for a rollover. This method is called prior to closing the active log file, performs any necessary
- * preliminary actions and describes actions needed after close of current log file.
- *
- * @param manager The RollingFileManager name for current active log file.
- * @return Description of pending rollover, may be null to indicate no rollover at this time.
- * @throws SecurityException if denied access to log files.
+ /**
+ * Prepare for a rollover. This method is called prior to closing the active log file, performs any necessary
+ * preliminary actions and describes actions needed after close of current log file.
+ *
+ * @param manager The RollingFileManager name for current active log file.
+ * @return Description of pending rollover, may be null to indicate no rollover at this time.
+ * @throws SecurityException if denied access to log files.
*/
- public RolloverDescription rollover(final RollingFileManager manager) throws SecurityException;
+ RolloverDescription rollover(final RollingFileManager manager) throws SecurityException;
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategyBase.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/appender/rolling/RolloverStrategyBase.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategyBase.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RolloverStrategyBase.java Thu Dec 22 07:43:55 2011
@@ -27,5 +27,5 @@ public abstract class RolloverStrategyBa
/**
* Allow subclasses access to the status logger without creating another instance.
*/
- protected static final Logger logger = StatusLogger.getLogger();
+ protected static final Logger LOGGER = StatusLogger.getLogger();
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/SizeBasedTriggeringPolicy.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/appender/rolling/SizeBasedTriggeringPolicy.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/SizeBasedTriggeringPolicy.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/SizeBasedTriggeringPolicy.java Thu Dec 22 07:43:55 2011
@@ -34,8 +34,10 @@ import java.util.regex.Pattern;
*/
@Plugin(name = "SizeBasedTriggeringPolicy", type = "Core", printObject = true)
public class SizeBasedTriggeringPolicy implements TriggeringPolicy {
-
- protected static final Logger logger = StatusLogger.getLogger();
+ /**
+ * Allow subclasses access to the status logger without creating another instance.
+ */
+ protected static final Logger LOGGER = StatusLogger.getLogger();
private static final long KB = 1024;
private static final long MB = KB * KB;
@@ -50,7 +52,7 @@ public class SizeBasedTriggeringPolicy i
/**
* Pattern for string parsing.
*/
- private static final Pattern valuePattern =
+ private static final Pattern VALUE_PATTERN =
Pattern.compile("([0-9]+([\\.,][0-9]+)?)\\s*(|K|M|G)B?", Pattern.CASE_INSENSITIVE);
private final long maxFileSize;
@@ -60,31 +62,47 @@ public class SizeBasedTriggeringPolicy i
/**
* Constructs a new instance.
*/
- public SizeBasedTriggeringPolicy() {
+ protected SizeBasedTriggeringPolicy() {
this.maxFileSize = MAX_FILE_SIZE;
}
- public void initialize(RollingFileManager manager) {
- this.manager = manager;
- }
-
/**
* Constructs a new instance.
*
* @param maxFileSize rollover threshold size in bytes.
*/
- public SizeBasedTriggeringPolicy(final long maxFileSize) {
+ protected SizeBasedTriggeringPolicy(final long maxFileSize) {
this.maxFileSize = maxFileSize;
}
+ /**
+ * Initialize the TriggeringPolicy.
+ * @param manager The RollingFileManager.
+ */
+ public void initialize(RollingFileManager manager) {
+ this.manager = manager;
+ }
+
+
+ /**
+ * Returns true if a rollover should occur.
+ * @param event A reference to the currently event.
+ * @return true if a rollover should take place, false otherwise.
+ */
public boolean isTriggeringEvent(LogEvent event) {
return manager.getFileSize() > maxFileSize;
}
+ @Override
public String toString() {
- return "SizeBasedTriggeringPolicy(size=" + maxFileSize +")";
+ return "SizeBasedTriggeringPolicy(size=" + maxFileSize + ")";
}
+ /**
+ * Create a SizeBasedTriggeringPolicy.
+ * @param size The size of the file before rollover is required.
+ * @return A SizeBasedTriggeringPolicy.
+ */
@PluginFactory
public static SizeBasedTriggeringPolicy createPolicy(@PluginAttr("size") String size) {
@@ -100,8 +118,8 @@ public class SizeBasedTriggeringPolicy i
* @param string The string to convert
* @return The Bytes value for the string
*/
- private static long valueOf(final String string){
- final Matcher matcher = valuePattern.matcher(string);
+ private static long valueOf(final String string) {
+ final Matcher matcher = VALUE_PATTERN.matcher(string);
// Valid input?
if (matcher.matches()) {
@@ -122,15 +140,15 @@ public class SizeBasedTriggeringPolicy i
} else if (units.equalsIgnoreCase("G")) {
return value * GB;
} else {
- logger.error("Units not recognized: " + string);
+ LOGGER.error("Units not recognized: " + string);
return MAX_FILE_SIZE;
}
} catch (ParseException e) {
- logger.error("Unable to parse numeric part: " + string, e);
+ LOGGER.error("Unable to parse numeric part: " + string, e);
return MAX_FILE_SIZE;
}
} else {
- logger.error("Unable to parse bytes: " + string);
+ LOGGER.error("Unable to parse bytes: " + string);
return MAX_FILE_SIZE;
}
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.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/appender/rolling/TriggeringPolicy.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java Thu Dec 22 07:43:55 2011
@@ -25,7 +25,12 @@ import org.apache.logging.log4j.core.Log
*/
public interface TriggeringPolicy {
- public void initialize(final RollingFileManager manager);
+ /**
+ * Initialize the Policy.
+ * @param manager The RollingFileManager.
+ */
+
+ void initialize(final RollingFileManager manager);
/**
* Determines if a rollover may be appropriate at this time. If
@@ -33,8 +38,7 @@ public interface TriggeringPolicy {
* can determine that a rollover is not warranted.
*
* @param event A reference to the currently event.
- * @param manager The RollingFileManager for the active file.
* @return true if a rollover should occur.
*/
- public boolean isTriggeringEvent(final LogEvent event);
+ boolean isTriggeringEvent(final LogEvent event);
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/Action.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/appender/rolling/helper/Action.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/Action.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/Action.java Thu Dec 22 07:43:55 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.core.appender.rolling.helper;
import java.io.IOException;
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ActionBase.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/appender/rolling/helper/ActionBase.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ActionBase.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ActionBase.java Thu Dec 22 07:43:55 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.core.appender.rolling.helper;
import org.apache.logging.log4j.Logger;
@@ -28,6 +27,10 @@ import java.io.IOException;
*/
public abstract class ActionBase implements Action {
/**
+ * Allow subclasses access to the status logger without creating another instance.
+ */
+ protected static final Logger LOGGER = StatusLogger.getLogger();
+ /**
* Is action complete.
*/
private boolean complete = false;
@@ -38,11 +41,6 @@ public abstract class ActionBase impleme
private boolean interrupted = false;
/**
- * Allow subclasses access to the status logger without creating another instance.
- */
- protected static final Logger LOGGER = StatusLogger.getLogger();
-
- /**
* Constructor.
*/
protected ActionBase() {
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/CompositeAction.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/appender/rolling/helper/CompositeAction.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/CompositeAction.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/CompositeAction.java Thu Dec 22 07:43:55 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.core.appender.rolling.helper;
import java.io.IOException;
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/FileRenameAction.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/appender/rolling/helper/FileRenameAction.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/FileRenameAction.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/FileRenameAction.java Thu Dec 22 07:43:55 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.core.appender.rolling.helper;
import java.io.File;
@@ -108,9 +107,8 @@ public final class FileRenameAction exte
srcChannel = srcStream.getChannel();
destChannel = destStream.getChannel();
destChannel.transferFrom(srcChannel, 0, srcChannel.size());
- }
- finally {
- if(srcChannel != null) {
+ } finally {
+ if (srcChannel != null) {
srcChannel.close();
}
if (srcStream != null) {
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/GZCompressAction.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/appender/rolling/helper/GZCompressAction.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/GZCompressAction.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/GZCompressAction.java Thu Dec 22 07:43:55 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.core.appender.rolling.helper;
import java.io.BufferedOutputStream;
@@ -44,6 +43,8 @@ public final class GZCompressAction exte
*/
private final boolean deleteSource;
+ private static final int BUF_SIZE = 8102;
+
/**
* Create new instance of GZCompressAction.
@@ -94,7 +95,7 @@ public final class GZCompressAction exte
FileOutputStream fos = new FileOutputStream(destination);
GZIPOutputStream gzos = new GZIPOutputStream(fos);
BufferedOutputStream os = new BufferedOutputStream(gzos);
- byte[] inbuf = new byte[8102];
+ byte[] inbuf = new byte[BUF_SIZE];
int n;
while ((n = fis.read(inbuf)) != -1) {
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ZipCompressAction.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/appender/rolling/helper/ZipCompressAction.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ZipCompressAction.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/helper/ZipCompressAction.java Thu Dec 22 07:43:55 2011
@@ -1,20 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * 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 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
+ * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.core.appender.rolling.helper;
import java.io.File;
@@ -45,6 +44,8 @@ public final class ZipCompressAction ext
*/
private final boolean deleteSource;
+ private static final int BUF_SIZE = 8102;
+
/**
* Create new instance of GZCompressAction.
@@ -98,7 +99,7 @@ public final class ZipCompressAction ext
ZipEntry zipEntry = new ZipEntry(source.getName());
zos.putNextEntry(zipEntry);
- byte[] inbuf = new byte[8102];
+ byte[] inbuf = new byte[BUF_SIZE];
int n;
while ((n = fis.read(inbuf)) != -1) {
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Route.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/appender/routing/Route.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Route.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Route.java Thu Dec 22 07:43:55 2011
@@ -29,11 +29,11 @@ import org.apache.logging.log4j.status.S
*/
@Plugin(name = "Route", type = "Core", printObject = true, deferChildren = true)
public final class Route {
+ private static final Logger LOGGER = StatusLogger.getLogger();
private final Node node;
private final String appenderRef;
private final String key;
- private static final Logger logger = StatusLogger.getLogger();
private Route(Node node, String appenderRef, String key) {
this.node = node;
@@ -99,12 +99,12 @@ public final class Route {
}
if (appenderRef != null) {
- logger.error("A route cannot be configured with an appender reference and an appender definition");
+ LOGGER.error("A route cannot be configured with an appender reference and an appender definition");
return null;
}
} else {
if (appenderRef == null) {
- logger.error("A route must specify an appender reference or an appender definition");
+ LOGGER.error("A route must specify an appender reference or an appender definition");
return null;
}
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.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/appender/routing/Routes.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java Thu Dec 22 07:43:55 2011
@@ -17,37 +17,45 @@
package org.apache.logging.log4j.core.appender.routing;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.Node;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAttr;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.config.plugins.PluginNode;
import org.apache.logging.log4j.status.StatusLogger;
/**
- *
+ * Used to contain the individual Route elements.
*/
-@Plugin(name="Routes", type="Core", printObject=true)
-public class Routes {
+@Plugin(name = "Routes", type = "Core", printObject = true)
+public final class Routes {
+
+ private static final Logger LOGGER = StatusLogger.getLogger();
private final String pattern;
private final Route[] routes;
- private static final Logger logger = StatusLogger.getLogger();
private Routes(String pattern, Route[] routes) {
this.pattern = pattern;
this.routes = routes;
}
+ /**
+ * Return the pattern.
+ * @return the pattern.
+ */
public String getPattern() {
return pattern;
}
+ /**
+ * Return the array of Route elements.
+ * @return an array of Route elements.
+ */
public Route[] getRoutes() {
return routes;
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder("{");
boolean first = true;
@@ -63,15 +71,21 @@ public class Routes {
}
+ /**
+ * Create the Routes.
+ * @param pattern The pattern.
+ * @param routes An array of Route elements.
+ * @return The Routes container.
+ */
@PluginFactory
public static Routes createRoutes(@PluginAttr("pattern") String pattern,
@PluginElement("routes") Route[] routes) {
if (pattern == null) {
- logger.error("A pattern is required");
+ LOGGER.error("A pattern is required");
return null;
}
if (routes == null || routes.length == 0) {
- logger.error("No routes configured");
+ LOGGER.error("No routes configured");
return null;
}
return new Routes(pattern, routes);
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.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/appender/routing/RoutingAppender.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java Thu Dec 22 07:43:55 2011
@@ -42,8 +42,8 @@ import java.util.concurrent.ConcurrentMa
* the form "$${[key:]token}". The pattern will be resolved each time the Appender is called using
* the built in StrSubstitutor and the StrLookup plugin that matches the specified key.
*/
-@Plugin(name="Routing",type="Core",elementType="appender",printObject=true)
-public class RoutingAppender extends AppenderBase {
+@Plugin(name = "Routing", type = "Core", elementType = "appender", printObject = true)
+public final class RoutingAppender extends AppenderBase {
private static final String DEFAULT_KEY = "ROUTING_APPENDER_DEFAULT";
private final Routes routes;
private final Configuration config;
@@ -163,6 +163,17 @@ public class RoutingAppender extends App
return null;
}
+ /**
+ * Create a RoutingAppender.
+ * @param name The name of the Appender.
+ * @param suppress "true" if exceptions should be hidden from the application, "false" otherwise.
+ * The default is "true".
+ * @param routes The routing definitions.
+ * @param config The Configuration (automatically added by the Configuration).
+ * @param rewritePolicy A RewritePolicy, if any.
+ * @param filter A Filter to restrict events processed by the Appender or null.
+ * @return The RoutingAppender
+ */
@PluginFactory
public static RoutingAppender createAppender(@PluginAttr("name") String name,
@PluginAttr("suppressExceptions") String suppress,
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=1222082&r1=1222081&r2=1222082&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 Thu Dec 22 07:43:55 2011
@@ -16,12 +16,10 @@
*/
package org.apache.logging.log4j.core.config;
-import org.apache.logging.log4j.core.ErrorHandler;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Lifecycle;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AppenderRuntimeException;
-import org.apache.logging.log4j.core.appender.DefaultErrorHandler;
import org.apache.logging.log4j.core.filter.Filtering;
/**
@@ -61,13 +59,12 @@ public class AppenderControl {
try {
recursive.set(this);
- if (appender instanceof Lifecycle) {
- if (!appender.isStarted()) {
- appender.getHandler().error("Attempted to append to non-started appender " + appender.getName());
-
- if (!appender.isExceptionSuppressed()) {
- throw new AppenderRuntimeException("Attempted to append to non-started appender " + appender.getName());
- }
+ if (appender instanceof Lifecycle && !appender.isStarted()) {
+ appender.getHandler().error("Attempted to append to non-started appender " + appender.getName());
+
+ if (!appender.isExceptionSuppressed()) {
+ throw new AppenderRuntimeException(
+ "Attempted to append to non-started 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=1222082&r1=1222081&r2=1222082&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 Thu Dec 22 07:43:55 2011
@@ -52,12 +52,12 @@ import java.util.concurrent.CopyOnWriteA
*/
public class BaseConfiguration extends Filterable implements Configuration {
+ protected final static Logger LOGGER = StatusLogger.getLogger();
+
protected Node rootNode;
protected PluginManager pluginManager;
- protected final static Logger logger = StatusLogger.getLogger();
-
protected final List<ConfigurationListener> listeners =
new CopyOnWriteArrayList<ConfigurationListener>();
@@ -139,7 +139,7 @@ public class BaseConfiguration extends F
if (subst.getVariableResolver() == null) {
subst.setVariableResolver((StrLookup) child.getObject());
} else {
- logger.error("Properties declaration must be the first element in the configuration");
+ LOGGER.error("Properties declaration must be the first element in the configuration");
}
continue;
}
@@ -159,15 +159,15 @@ public class BaseConfiguration extends F
setRoot = true;
}
} else {
- logger.error("Unknown object \"" + child.getName() + "\" of type " +
+ LOGGER.error("Unknown object \"" + child.getName() + "\" of type " +
child.getObject().getClass().getName() + " is ignored");
}
}
if (!setLoggers) {
- logger.warn("No Loggers were configured, using default");
+ LOGGER.warn("No Loggers were configured, using default");
} else if (!setRoot) {
- logger.warn("No Root logger was configured, using default");
+ LOGGER.warn("No Root logger was configured, using default");
}
root.setConfigurationMonitor(monitor);
@@ -180,7 +180,7 @@ public class BaseConfiguration extends F
if (app != null) {
l.addAppender(app);
} else {
- logger.error("Unable to locate appender " + ref + " for logger " + l.getName());
+ LOGGER.error("Unable to locate appender " + ref + " for logger " + l.getName());
}
}
@@ -399,7 +399,7 @@ public class BaseConfiguration extends F
public void addLogger(String name, LoggerConfig loggerConfig) {
if (started) {
String msg = "Cannot add logger " + name + " to an active configuration";
- logger.warn(msg);
+ LOGGER.warn(msg);
throw new IllegalStateException(msg);
}
loggers.put(name, loggerConfig);
@@ -415,7 +415,7 @@ public class BaseConfiguration extends F
public void removeLogger(String name) {
if (started) {
String msg = "Cannot remove logger " + name + " in an active configuration";
- logger.warn(msg);
+ LOGGER.warn(msg);
throw new IllegalStateException(msg);
}
loggers.remove(name);
@@ -433,7 +433,7 @@ public class BaseConfiguration extends F
if (type == null) {
if (node.getParent() != null) {
- logger.error("Unable to locate plugin for " + node.getName());
+ LOGGER.error("Unable to locate plugin for " + node.getName());
}
} else {
node.setObject(createPluginObject(type, node, event));
@@ -441,54 +441,6 @@ public class BaseConfiguration extends F
}
}
- /**
- * Create an Object that will contain its child Nodes and defer their construction until
- * a later time.
- * @param type The PluginType.
- * @param node The Node.
- * @return The constructed container object.
- */
- private Object createPluginContainer(PluginType type, Node node) {
- Class clazz = type.getPluginClass();
- Method factoryMethod = null;
-
- for (Method method : clazz.getMethods()) {
- if (method.isAnnotationPresent(PluginFactory.class)) {
- factoryMethod = method;
- break;
- }
- }
- if (factoryMethod == null) {
- return null;
- }
- Class[] parmClasses = factoryMethod.getParameterTypes();
- if (parmClasses.length != 1 && Node.class.equals(parmClasses[0])) {
- logger.error("Template factory method must contain a single Node parameter");
- }
-
- try
- {
- int mod = factoryMethod.getModifiers();
- if (!Modifier.isStatic(mod))
- {
- logger.error(factoryMethod.getName() + " method is not static on class " +
- clazz.getName() + " for element " + node.getName());
- return null;
- }
- logger.debug("Calling " + factoryMethod.getName() + " on class " + clazz.getName() + " for element " +
- node.getName());
-
- return factoryMethod.invoke(null, node);
- }
- catch (Exception e)
- {
- logger.error("Unable to invoke method " + factoryMethod.getName() + " in class " +
- clazz.getName() + " for element " + node.getName(), e);
- }
- return null;
-
- }
-
/*
* Retrieve a static public 'method to create the desired object. Every parameter
* will be annotated to identify the appropriate attribute or element to use to
@@ -510,25 +462,27 @@ public class BaseConfiguration extends F
if (Map.class.isAssignableFrom(clazz)) {
try {
- Map map = (Map) clazz.newInstance();
+ Map<String, Object> map = (Map<String, Object>) clazz.newInstance();
for (Node child : node.getChildren()) {
map.put(child.getName(), child.getObject());
}
return map;
} catch (Exception ex) {
-
+ LOGGER.warn("Unable to create Map for " + type.getElementName() + " of class " +
+ clazz);
}
}
if (List.class.isAssignableFrom(clazz)) {
try {
- List list = (List) clazz.newInstance();
+ List<Object> list = (List<Object>) clazz.newInstance();
for (Node child : node.getChildren()) {
list.add(child.getObject());
}
return list;
} catch (Exception ex) {
-
+ LOGGER.warn("Unable to create List for " + type.getElementName() + " of class " +
+ clazz);
}
}
@@ -547,7 +501,7 @@ public class BaseConfiguration extends F
Annotation[][] parmArray = factoryMethod.getParameterAnnotations();
Class[] parmClasses = factoryMethod.getParameterTypes();
if (parmArray.length != parmClasses.length) {
- logger.error("Number of parameter annotations does not equal the number of paramters");
+ LOGGER.error("Number of parameter annotations does not equal the number of paramters");
}
Object[] parms = new Object[parmClasses.length];
@@ -684,7 +638,7 @@ public class BaseConfiguration extends F
eb.append("\"");
}
- logger.error(eb.toString());
+ LOGGER.error(eb.toString());
}
if (!type.isDeferChildren() && used.size() != children.size()) {
@@ -694,7 +648,7 @@ public class BaseConfiguration extends F
}
String nodeType = node.getType().getElementName();
String start = nodeType.equals(node.getName()) ? node.getName() : nodeType + " " + node.getName();
- logger.error(start + " has no parameter that matches element " + child.getName());
+ LOGGER.error(start + " has no parameter that matches element " + child.getName());
}
}
@@ -703,11 +657,11 @@ public class BaseConfiguration extends F
int mod = factoryMethod.getModifiers();
if (!Modifier.isStatic(mod))
{
- logger.error(factoryMethod.getName() + " method is not static on class " +
+ LOGGER.error(factoryMethod.getName() + " method is not static on class " +
clazz.getName() + " for element " + node.getName());
return null;
}
- logger.debug("Calling " + factoryMethod.getName() + " on class " + clazz.getName() + " for element " +
+ LOGGER.debug("Calling " + factoryMethod.getName() + " on class " + clazz.getName() + " for element " +
node.getName() + sb.toString());
//if (parms.length > 0) {
return factoryMethod.invoke(null, parms);
@@ -716,7 +670,7 @@ public class BaseConfiguration extends F
}
catch (Exception e)
{
- logger.error("Unable to invoke method " + factoryMethod.getName() + " in class " +
+ LOGGER.error("Unable to invoke method " + factoryMethod.getName() + " in class " +
clazz.getName() + " for element " + node.getName(), e);
}
return null;
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=1222082&r1=1222081&r2=1222082&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 Thu Dec 22 07:43:55 2011
@@ -23,8 +23,6 @@ import org.apache.logging.log4j.core.Log
import org.apache.logging.log4j.core.filter.Filtering;
import org.apache.logging.log4j.core.lookup.StrSubstitutor;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
/**
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.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/ConfigurationFactory.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java Thu Dec 22 07:43:55 2011
@@ -59,10 +59,10 @@ public abstract class ConfigurationFacto
public static final String CONFIGURATION_FILE_PROPERTY = "log4j.configurationFile";
- private static List<ConfigurationFactory> factories = new ArrayList<ConfigurationFactory>();
-
protected static final Logger LOGGER = StatusLogger.getLogger();
+ private static List<ConfigurationFactory> factories = new ArrayList<ConfigurationFactory>();
+
protected File configFile = null;
protected static final String TEST_PREFIX = "log4j2-test";
@@ -71,6 +71,10 @@ public abstract class ConfigurationFacto
private static ConfigurationFactory configFactory = new Factory();
+ /**
+ * Return the ConfigurationFactory.
+ * @return the ConfigurationFactory.
+ */
public static ConfigurationFactory getInstance() {
String factoryClass = System.getProperty(CONFIGURATION_FACTORY_PROPERTY);
if (factoryClass != null) {
@@ -89,7 +93,7 @@ public abstract class ConfigurationFacto
ordered.add(new WeightedFactory(weight, clazz));
}
} catch (Exception ex) {
-
+ LOGGER.warn("Unable to add class " + type.getPluginClass());
}
}
for (WeightedFactory wf : ordered) {
@@ -117,14 +121,25 @@ public abstract class ConfigurationFacto
}
}
+ /**
+ * Set the configuration factory.
+ * @param factory the ConfigurationFactory.
+ */
public static void setConfigurationFactory(ConfigurationFactory factory) {
configFactory = factory;
}
+ /**
+ * Reset the ConfigurationFactory to the default.
+ */
public static void resetConfigurationFactory() {
configFactory = new Factory();
}
+ /**
+ * Remove the ConfigurationFactory.
+ * @param factory The factory to remove.
+ */
public static void removeConfigurationFactory(ConfigurationFactory factory) {
factories.remove(factory);
}
@@ -137,6 +152,12 @@ public abstract class ConfigurationFacto
public abstract Configuration getConfiguration(InputSource source);
+ /**
+ * Return the Configuration.
+ * @param name The configuration name.
+ * @param configLocation The configuration location.
+ * @return The Configuration.
+ */
public Configuration getConfiguration(String name, URI configLocation) {
if (!isActive()) {
return null;
@@ -205,10 +226,18 @@ public abstract class ConfigurationFacto
return source;
}
+ /**
+ * Factory that chooses a ConfigurationFactory based on weighting.
+ */
private static class WeightedFactory implements Comparable<WeightedFactory> {
private int weight;
private Class<ConfigurationFactory> factoryClass;
+ /**
+ * Constructor.
+ * @param weight The weight.
+ * @param clazz The class.
+ */
public WeightedFactory(int weight, Class<ConfigurationFactory> clazz) {
this.weight = weight;
this.factoryClass = clazz;
@@ -226,8 +255,17 @@ public abstract class ConfigurationFacto
}
}
+ /**
+ * Default Factory.
+ */
private static class Factory extends ConfigurationFactory {
+ /**
+ * Default Factory Constructor.
+ * @param name The configuration name.
+ * @param configLocation The configuration location.
+ * @return The Configuration.
+ */
public Configuration getConfiguration(String name, URI configLocation) {
if (configLocation == null) {
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=1222082&r1=1222081&r2=1222082&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 Thu Dec 22 07:43:55 2011
@@ -19,7 +19,6 @@ package org.apache.logging.log4j.core.co
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.ConsoleAppender;
import org.apache.logging.log4j.core.layout.PatternLayout;
@@ -40,8 +39,6 @@ public class DefaultConfiguration extend
*/
public static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
- private static final String EMPTY_STRING = "";
-
/**
* Constructor to create the default configuration.
*/
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.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/JSONConfiguration.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/JSONConfiguration.java Thu Dec 22 07:43:55 2011
@@ -84,7 +84,7 @@ public class JSONConfiguration extends B
}
}
- Iterator<StatusListener> statusIter = ((StatusLogger) logger).getListeners();
+ Iterator<StatusListener> statusIter = ((StatusLogger) LOGGER).getListeners();
boolean found = false;
while (statusIter.hasNext()) {
StatusListener listener = statusIter.next();
@@ -101,13 +101,13 @@ public class JSONConfiguration extends B
if (!verbose) {
listener.setFilters(verboseClasses);
}
- ((StatusLogger) logger).registerListener(listener);
+ ((StatusLogger) LOGGER).registerListener(listener);
}
if (getName() == null) {
setName(source.getSystemId());
}
} catch (Exception ex) {
- logger.error("Error parsing " + source.getSystemId(), ex);
+ LOGGER.error("Error parsing " + source.getSystemId(), ex);
ex.printStackTrace();
}
}
@@ -119,16 +119,16 @@ public class JSONConfiguration extends B
Map.Entry<String, JsonNode> entry = iter.next();
JsonNode n = entry.getValue();
if (n.isObject()) {
- logger.debug("Processing node for object " + entry.getKey());
+ LOGGER.debug("Processing node for object " + entry.getKey());
children.add(constructNode(entry.getKey(), rootNode, n));
} else if (n.isArray()) {
- logger.error("Arrays are not supported at the root configuration.");
+ LOGGER.error("Arrays are not supported at the root configuration.");
}
}
- logger.debug("Completed parsing configuration");
+ LOGGER.debug("Completed parsing configuration");
if (status.size() > 0) {
for (Status s : status) {
- logger.error("Error processing element " + s.name + ": " + s.errorType);
+ LOGGER.error("Error processing element " + s.name + ": " + s.errorType);
}
return;
}
@@ -148,30 +148,30 @@ public class JSONConfiguration extends B
status.add(new Status(name, n, ErrorType.CLASS_NOT_FOUND));
}
if (n.isArray()) {
- logger.debug("Processing node for array " + entry.getKey());
+ LOGGER.debug("Processing node for array " + entry.getKey());
for (int i=0; i < n.size(); ++i) {
String pluginType = getType(n.get(i), entry.getKey());
PluginType entryType = getPluginManager().getPluginType(pluginType);
Node item = new Node(node, entry.getKey(), entryType);
processAttributes(item, n.get(i));
if (pluginType.equals(entry.getKey())) {
- logger.debug("Processing " + entry.getKey() + "[" + i + "]");
+ LOGGER.debug("Processing " + entry.getKey() + "[" + i + "]");
} else {
- logger.debug("Processing " + pluginType + " " + entry.getKey() + "[" + i + "]");
+ LOGGER.debug("Processing " + pluginType + " " + entry.getKey() + "[" + i + "]");
}
Iterator<Map.Entry<String, JsonNode>> itemIter = n.get(i).getFields();
List<Node> itemChildren = item.getChildren();
while (itemIter.hasNext()) {
Map.Entry<String, JsonNode> itemEntry = itemIter.next();
if (itemEntry.getValue().isObject()) {
- logger.debug("Processing node for object " + itemEntry.getKey());
+ LOGGER.debug("Processing node for object " + itemEntry.getKey());
itemChildren.add(constructNode(itemEntry.getKey(), item, itemEntry.getValue()));
}
}
children.add(item);
}
} else {
- logger.debug("Processing node for object " + entry.getKey());
+ LOGGER.debug("Processing node for object " + entry.getKey());
children.add(constructNode(entry.getKey(), node, n));
}
}
@@ -185,7 +185,7 @@ public class JSONConfiguration extends B
}
String p = node.getParent() == null ? "null" : node.getParent().getName() == null ? "root" : node.getParent().getName();
- logger.debug("Returning " + node.getName() + " with parent " + p + " of type " + t);
+ LOGGER.debug("Returning " + node.getName() + " with parent " + p + " of type " + t);
return node;
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.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/XMLConfiguration.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfiguration.java Thu Dec 22 07:43:55 2011
@@ -106,7 +106,7 @@ public class XMLConfiguration extends Ba
}
}
}
- Iterator<StatusListener> iter = ((StatusLogger)logger).getListeners();
+ Iterator<StatusListener> iter = ((StatusLogger) LOGGER).getListeners();
boolean found = false;
while (iter.hasNext()) {
StatusListener listener = iter.next();
@@ -123,22 +123,22 @@ public class XMLConfiguration extends Ba
if (!verbose) {
listener.setFilters(verboseClasses);
}
- ((StatusLogger) logger).registerListener(listener);
+ ((StatusLogger) LOGGER).registerListener(listener);
}
} catch (SAXException domEx) {
- logger.error("Error parsing " + source.getSystemId(), domEx);
+ LOGGER.error("Error parsing " + source.getSystemId(), domEx);
} catch (IOException ioe) {
- logger.error("Error parsing " + source.getSystemId(), ioe);
+ LOGGER.error("Error parsing " + source.getSystemId(), ioe);
} catch (ParserConfigurationException pex) {
- logger.error("Error parsing " + source.getSystemId(), pex);
+ LOGGER.error("Error parsing " + source.getSystemId(), pex);
}
if (strict && schema != null && buffer != null) {
InputStream is = null;
try {
is = getClass().getClassLoader().getResourceAsStream(schema);
} catch (Exception ex) {
- logger.error("Unable to access schema " + schema);
+ LOGGER.error("Unable to access schema " + schema);
}
if (is != null) {
Source src = new StreamSource(is, LOG4J_XSD);
@@ -147,16 +147,16 @@ public class XMLConfiguration extends Ba
try {
schema = factory.newSchema(src);
} catch (SAXException ex) {
- logger.error("Error parsing Log4j schema", ex);
+ LOGGER.error("Error parsing Log4j schema", ex);
}
if (schema != null) {
validator = schema.newValidator();
try {
validator.validate(new StreamSource(new ByteArrayInputStream(buffer)));
} catch (IOException ioe) {
- logger.error("Error reading configuration for validation", ioe);
+ LOGGER.error("Error reading configuration for validation", ioe);
} catch (SAXException ex) {
- logger.error("Error validating configuration", ex);
+ LOGGER.error("Error validating configuration", ex);
}
}
}
@@ -171,7 +171,7 @@ public class XMLConfiguration extends Ba
constructHierarchy(rootNode, rootElement);
if (status.size() > 0) {
for (Status s : status) {
- logger.error("Error processing element " + s.name + ": " + s.errorType);
+ LOGGER.error("Error processing element " + s.name + ": " + s.errorType);
}
return;
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfigurationFactory.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/XMLConfigurationFactory.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfigurationFactory.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/XMLConfigurationFactory.java Thu Dec 22 07:43:55 2011
@@ -19,21 +19,31 @@ package org.apache.logging.log4j.core.co
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.xml.sax.InputSource;
-import java.net.URI;
-
/**
- *
+ * Factory to coonstruct an XMLConfiguration.
*/
-@Plugin(name="XMLConfigurationFactory", type="ConfigurationFactory")
+@Plugin(name = "XMLConfigurationFactory", type = "ConfigurationFactory")
@Order(5)
public class XMLConfigurationFactory extends ConfigurationFactory {
+ /**
+ * Valid file extensions for XML files.
+ */
public static final String[] SUFFIXES = new String[] {".xml", "*"};
+ /**
+ * Return the Configuration.
+ * @param source The InputSource.
+ * @return The Configuration.
+ */
public Configuration getConfiguration(InputSource source) {
return new XMLConfiguration(source, configFile);
}
+ /**
+ * Returns the file suffixes for XML files.
+ * @return An array of File extensions.
+ */
public String[] getSupportedTypes() {
return SUFFIXES;
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.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/plugins/PluginManager.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginManager.java Thu Dec 22 07:43:55 2011
@@ -34,24 +34,23 @@ import java.util.concurrent.ConcurrentMa
import java.util.concurrent.CopyOnWriteArrayList;
/**
- *
+ * Component that loads and manages all the plugins.
*/
public class PluginManager {
private static long NANOS_PER_SECOND = 1000000000L;
- private Map<String, PluginType> plugins = new HashMap<String, PluginType>();
private static ConcurrentMap<String, ConcurrentMap<String, PluginType>> pluginTypeMap =
new ConcurrentHashMap<String, ConcurrentMap<String, PluginType>>();
private static CopyOnWriteArrayList<String> packages = new CopyOnWriteArrayList<String>();
private static final String PATH = "org/apache/logging/log4j/core/config/plugins/";
- private static final String PREFIX = "Log4j2";
private static final String FILENAME = "Log4j2Plugins.dat";
private static final String LOG4J_PACKAGES = "org.apache.logging.log4j.core";
- private static Logger logger = StatusLogger.getLogger();
+ private static Logger LOGGER = StatusLogger.getLogger();
+ private Map<String, PluginType> plugins = new HashMap<String, PluginType>();
private final String type;
private final Class clazz;
private static String rootDir;
@@ -113,7 +112,7 @@ public class PluginManager {
pluginTypeMap = map;
plugins = map.get(type);
} else {
- logger.warn("Plugin preloads not available");
+ LOGGER.warn("Plugin preloads not available");
}
}
if (plugins.size() == 0) {
@@ -144,11 +143,7 @@ public class PluginManager {
sb.append(numFormat.format(seconds)).append(".");
numFormat = new DecimalFormat("000000000");
sb.append(numFormat.format(elapsed)).append(" seconds");
- logger.debug(sb.toString());
- }
-
- private static String createClassName(String type, String suffix) {
- return PREFIX + type + suffix;
+ LOGGER.debug(sb.toString());
}
private static ConcurrentMap<String, ConcurrentMap<String, PluginType>> decode(ClassLoader loader) {
@@ -178,7 +173,7 @@ public class PluginManager {
dis.close();
return map;
} catch (Exception ex) {
- logger.warn("Unable to preload plugins", ex);
+ LOGGER.warn("Unable to preload plugins", ex);
return null;
}
}
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PropertiesPlugin.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/plugins/PropertiesPlugin.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PropertiesPlugin.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PropertiesPlugin.java Thu Dec 22 07:43:55 2011
@@ -20,17 +20,24 @@ import org.apache.logging.log4j.core.con
import org.apache.logging.log4j.core.lookup.Interpolator;
import org.apache.logging.log4j.core.lookup.MapLookup;
import org.apache.logging.log4j.core.lookup.StrLookup;
-import org.apache.logging.log4j.core.lookup.StrSubstitutor;
import java.util.HashMap;
import java.util.Map;
/**
- *
+ * Handles properties defined in the configuration.
*/
-@Plugin(name="properties", type="Core", printObject=true)
-public class PropertiesPlugin {
+@Plugin(name = "properties", type = "Core", printObject = true)
+public final class PropertiesPlugin {
+ private PropertiesPlugin() {
+ }
+
+ /**
+ * Create the Properties component.
+ * @param properties An array of Property elements.
+ * @return An Interpolator that includes the configuration properties.
+ */
@PluginFactory
public static StrLookup configureSubstitutor(@PluginElement("properties") Property[] properties) {
if (properties == null) {
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.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/BurstFilter.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java Thu Dec 22 07:43:55 2011
@@ -47,7 +47,7 @@ import java.util.concurrent.TimeUnit;
* <code>
* <Console name="console"><br>
* <PatternLayout pattern="%-5p %d{dd-MMM-yyyy HH:mm:ss} %x %t %m%n"/><br>
- * $lt;filters><br>
+ * <filters><br>
* <Burst level="INFO" rate="16" maxBurst="100"/><br>
* </filters><br>
* </Console><br>
Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.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/CompositeFilter.java?rev=1222082&r1=1222081&r2=1222082&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java (original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/CompositeFilter.java Thu Dec 22 07:43:55 2011
@@ -34,10 +34,10 @@ import java.util.Iterator;
import java.util.List;
/**
- *
+ * Filter that invokes multiple filters.
*/
-@Plugin(name="filters", type="Core", printObject=true)
-public class CompositeFilter implements Iterable<Filter>, Filter, Lifecycle {
+@Plugin(name = "filters", type = "Core", printObject = true)
+public final class CompositeFilter implements Iterable<Filter>, Filter, Lifecycle {
private final List<Filter> filters;
private final boolean hasFilters;
@@ -200,7 +200,7 @@ public class CompositeFilter implements
return result;
}
-
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (Filter filter : filters) {
@@ -217,6 +217,11 @@ public class CompositeFilter implements
return sb.toString();
}
+ /**
+ * Create a CompositeFilter.
+ * @param filters An array of Filters to call.
+ * @return The CompositeFilter.
+ */
@PluginFactory
public static CompositeFilter createFilters(@PluginElement("filters") Filter[] filters) {
List<Filter> f = filters == null || filters.length == 0 ? new ArrayList<Filter>() : Arrays.asList(filters);