You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/08/08 15:53:00 UTC
logging-log4j2 git commit: Javadoc: Use the active voice.
Repository: logging-log4j2
Updated Branches:
refs/heads/master 61f706fc0 -> 8ff086371
Javadoc: Use the active voice.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8ff08637
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8ff08637
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8ff08637
Branch: refs/heads/master
Commit: 8ff086371372022700e6bee3da4088e51cd66874
Parents: 61f706f
Author: Gary Gregory <gg...@apache.org>
Authored: Mon Aug 8 08:52:58 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Mon Aug 8 08:52:58 2016 -0700
----------------------------------------------------------------------
.../core/appender/RollingFileAppender.java | 404 +++++++++----------
1 file changed, 202 insertions(+), 202 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8ff08637/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
index 88bbb9a..2b06287 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
@@ -1,202 +1,202 @@
-/*
- * 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.appender;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.zip.Deflater;
-
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.RollingFileManager;
-import org.apache.logging.log4j.core.appender.rolling.RolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.core.net.Advertiser;
-import org.apache.logging.log4j.core.util.Booleans;
-import org.apache.logging.log4j.core.util.Integers;
-
-/**
- * An appender that writes to files and can roll over at intervals.
- */
-@Plugin(name = "RollingFile", category = "Core", elementType = "appender", printObject = true)
-public final class RollingFileAppender extends AbstractOutputStreamAppender<RollingFileManager> {
-
- private static final int DEFAULT_BUFFER_SIZE = 8192;
-
- private final String fileName;
- private final String filePattern;
- private Object advertisement;
- private final Advertiser advertiser;
-
- private RollingFileAppender(final String name, final Layout<? extends Serializable> layout, final Filter filter,
- final RollingFileManager manager, final String fileName, final String filePattern,
- final boolean ignoreExceptions, final boolean immediateFlush, final Advertiser advertiser) {
- super(name, layout, filter, ignoreExceptions, immediateFlush, manager);
- if (advertiser != null) {
- final Map<String, String> configuration = new HashMap<>(layout.getContentFormat());
- configuration.put("contentType", layout.getContentType());
- configuration.put("name", name);
- advertisement = advertiser.advertise(configuration);
- }
- this.fileName = fileName;
- this.filePattern = filePattern;
- this.advertiser = advertiser;
- }
-
- @Override
- public void stop() {
- super.stop();
- if (advertiser != null) {
- advertiser.unadvertise(advertisement);
- }
- }
-
- /**
- * Write the log entry rolling over the file when required.
-
- * @param event The LogEvent.
- */
- @Override
- public void append(final LogEvent event) {
- getManager().checkRollover(event);
- super.append(event);
- }
-
- /**
- * Returns the File name for the Appender.
- * @return The file name.
- */
- public String getFileName() {
- return fileName;
- }
-
- /**
- * Returns the file pattern used when rolling over.
- * @return The file pattern.
- */
- public String getFilePattern() {
- return filePattern;
- }
-
- /**
- * Returns the triggering policy.
- * @param <T> TriggeringPolicy type
- * @return The TriggeringPolicy
- */
- public <T extends TriggeringPolicy> T getTriggeringPolicy() {
- return getManager().getTriggeringPolicy();
- }
-
- /**
- * Create a RollingFileAppender.
- * @param fileName The name of the file that is actively written to. (required).
- * @param filePattern The pattern of the file name to use on rollover. (required).
- * @param append If true, events are appended to the file. If false, the file
- * is overwritten when opened. Defaults to "true"
- * @param name The name of the Appender (required).
- * @param bufferedIO When true, I/O will be buffered. Defaults to "true".
- * @param bufferSizeStr buffer size for buffered IO (default is 8192).
- * @param immediateFlush When true, events are immediately flushed. Defaults to "true".
- * @param policy The triggering policy. (required).
- * @param strategy The rollover strategy. Defaults to DefaultRolloverStrategy.
- * @param layout The layout to use (defaults to the default PatternLayout).
- * @param filter The Filter or null.
- * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
- * they are propagated to the caller.
- * @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
- * @param advertiseURI The advertised URI which can be used to retrieve the file contents.
- * @param config The Configuration.
- * @return A RollingFileAppender.
- */
- @PluginFactory
- public static RollingFileAppender createAppender(
- @PluginAttribute("fileName") final String fileName,
- @PluginAttribute("filePattern") final String filePattern,
- @PluginAttribute("append") final String append,
- @PluginAttribute("name") final String name,
- @PluginAttribute("bufferedIO") final String bufferedIO,
- @PluginAttribute("bufferSize") final String bufferSizeStr,
- @PluginAttribute("immediateFlush") final String immediateFlush,
- @PluginElement("Policy") final TriggeringPolicy policy,
- @PluginElement("Strategy") RolloverStrategy strategy,
- @PluginElement("Layout") Layout<? extends Serializable> layout,
- @PluginElement("Filter") final Filter filter,
- @PluginAttribute("ignoreExceptions") final String ignore,
- @PluginAttribute("advertise") final String advertise,
- @PluginAttribute("advertiseURI") final String advertiseURI,
- @PluginConfiguration final Configuration config) {
-
- final boolean isAppend = Booleans.parseBoolean(append, true);
- final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
- final boolean isBuffered = Booleans.parseBoolean(bufferedIO, true);
- final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
- final boolean isAdvertise = Boolean.parseBoolean(advertise);
- final int bufferSize = Integers.parseInt(bufferSizeStr, DEFAULT_BUFFER_SIZE);
- if (!isBuffered && bufferSize > 0) {
- LOGGER.warn("The bufferSize is set to {} but bufferedIO is not true: {}", bufferSize, bufferedIO);
- }
- if (name == null) {
- LOGGER.error("No name provided for FileAppender");
- return null;
- }
-
- if (fileName == null) {
- LOGGER.error("No filename was provided for FileAppender with name " + name);
- return null;
- }
-
- if (filePattern == null) {
- LOGGER.error("No filename pattern provided for FileAppender with name " + name);
- return null;
- }
-
- if (policy == null) {
- LOGGER.error("A TriggeringPolicy must be provided");
- return null;
- }
-
- if (strategy == null) {
- strategy = DefaultRolloverStrategy.createStrategy(null, null, null,
- String.valueOf(Deflater.DEFAULT_COMPRESSION), null, true, config);
- }
-
- if (layout == null) {
- layout = PatternLayout.createDefaultLayout();
- }
-
- final RollingFileManager manager = RollingFileManager.getFileManager(fileName, filePattern, isAppend,
- isBuffered, policy, strategy, advertiseURI, layout, bufferSize, isFlush);
- if (manager == null) {
- return null;
- }
-
- manager.initialize();
-
- return new RollingFileAppender(name, layout, filter, manager, fileName, filePattern,
- ignoreExceptions, isFlush, isAdvertise ? config.getAdvertiser() : null);
- }
-}
+/*
+ * 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.appender;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.Deflater;
+
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
+import org.apache.logging.log4j.core.appender.rolling.RollingFileManager;
+import org.apache.logging.log4j.core.appender.rolling.RolloverStrategy;
+import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
+import org.apache.logging.log4j.core.config.plugins.PluginElement;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+import org.apache.logging.log4j.core.net.Advertiser;
+import org.apache.logging.log4j.core.util.Booleans;
+import org.apache.logging.log4j.core.util.Integers;
+
+/**
+ * An appender that writes to files and can roll over at intervals.
+ */
+@Plugin(name = "RollingFile", category = "Core", elementType = "appender", printObject = true)
+public final class RollingFileAppender extends AbstractOutputStreamAppender<RollingFileManager> {
+
+ private static final int DEFAULT_BUFFER_SIZE = 8192;
+
+ private final String fileName;
+ private final String filePattern;
+ private Object advertisement;
+ private final Advertiser advertiser;
+
+ private RollingFileAppender(final String name, final Layout<? extends Serializable> layout, final Filter filter,
+ final RollingFileManager manager, final String fileName, final String filePattern,
+ final boolean ignoreExceptions, final boolean immediateFlush, final Advertiser advertiser) {
+ super(name, layout, filter, ignoreExceptions, immediateFlush, manager);
+ if (advertiser != null) {
+ final Map<String, String> configuration = new HashMap<>(layout.getContentFormat());
+ configuration.put("contentType", layout.getContentType());
+ configuration.put("name", name);
+ advertisement = advertiser.advertise(configuration);
+ }
+ this.fileName = fileName;
+ this.filePattern = filePattern;
+ this.advertiser = advertiser;
+ }
+
+ @Override
+ public void stop() {
+ super.stop();
+ if (advertiser != null) {
+ advertiser.unadvertise(advertisement);
+ }
+ }
+
+ /**
+ * Writes the log entry rolling over the file when required.
+
+ * @param event The LogEvent.
+ */
+ @Override
+ public void append(final LogEvent event) {
+ getManager().checkRollover(event);
+ super.append(event);
+ }
+
+ /**
+ * Returns the File name for the Appender.
+ * @return The file name.
+ */
+ public String getFileName() {
+ return fileName;
+ }
+
+ /**
+ * Returns the file pattern used when rolling over.
+ * @return The file pattern.
+ */
+ public String getFilePattern() {
+ return filePattern;
+ }
+
+ /**
+ * Returns the triggering policy.
+ * @param <T> TriggeringPolicy type
+ * @return The TriggeringPolicy
+ */
+ public <T extends TriggeringPolicy> T getTriggeringPolicy() {
+ return getManager().getTriggeringPolicy();
+ }
+
+ /**
+ * Creates a RollingFileAppender.
+ * @param fileName The name of the file that is actively written to. (required).
+ * @param filePattern The pattern of the file name to use on rollover. (required).
+ * @param append If true, events are appended to the file. If false, the file
+ * is overwritten when opened. Defaults to "true"
+ * @param name The name of the Appender (required).
+ * @param bufferedIO When true, I/O will be buffered. Defaults to "true".
+ * @param bufferSizeStr buffer size for buffered IO (default is 8192).
+ * @param immediateFlush When true, events are immediately flushed. Defaults to "true".
+ * @param policy The triggering policy. (required).
+ * @param strategy The rollover strategy. Defaults to DefaultRolloverStrategy.
+ * @param layout The layout to use (defaults to the default PatternLayout).
+ * @param filter The Filter or null.
+ * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
+ * they are propagated to the caller.
+ * @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
+ * @param advertiseURI The advertised URI which can be used to retrieve the file contents.
+ * @param config The Configuration.
+ * @return A RollingFileAppender.
+ */
+ @PluginFactory
+ public static RollingFileAppender createAppender(
+ @PluginAttribute("fileName") final String fileName,
+ @PluginAttribute("filePattern") final String filePattern,
+ @PluginAttribute("append") final String append,
+ @PluginAttribute("name") final String name,
+ @PluginAttribute("bufferedIO") final String bufferedIO,
+ @PluginAttribute("bufferSize") final String bufferSizeStr,
+ @PluginAttribute("immediateFlush") final String immediateFlush,
+ @PluginElement("Policy") final TriggeringPolicy policy,
+ @PluginElement("Strategy") RolloverStrategy strategy,
+ @PluginElement("Layout") Layout<? extends Serializable> layout,
+ @PluginElement("Filter") final Filter filter,
+ @PluginAttribute("ignoreExceptions") final String ignore,
+ @PluginAttribute("advertise") final String advertise,
+ @PluginAttribute("advertiseURI") final String advertiseURI,
+ @PluginConfiguration final Configuration config) {
+
+ final boolean isAppend = Booleans.parseBoolean(append, true);
+ final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
+ final boolean isBuffered = Booleans.parseBoolean(bufferedIO, true);
+ final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
+ final boolean isAdvertise = Boolean.parseBoolean(advertise);
+ final int bufferSize = Integers.parseInt(bufferSizeStr, DEFAULT_BUFFER_SIZE);
+ if (!isBuffered && bufferSize > 0) {
+ LOGGER.warn("The bufferSize is set to {} but bufferedIO is not true: {}", bufferSize, bufferedIO);
+ }
+ if (name == null) {
+ LOGGER.error("No name provided for FileAppender");
+ return null;
+ }
+
+ if (fileName == null) {
+ LOGGER.error("No filename was provided for FileAppender with name " + name);
+ return null;
+ }
+
+ if (filePattern == null) {
+ LOGGER.error("No filename pattern provided for FileAppender with name " + name);
+ return null;
+ }
+
+ if (policy == null) {
+ LOGGER.error("A TriggeringPolicy must be provided");
+ return null;
+ }
+
+ if (strategy == null) {
+ strategy = DefaultRolloverStrategy.createStrategy(null, null, null,
+ String.valueOf(Deflater.DEFAULT_COMPRESSION), null, true, config);
+ }
+
+ if (layout == null) {
+ layout = PatternLayout.createDefaultLayout();
+ }
+
+ final RollingFileManager manager = RollingFileManager.getFileManager(fileName, filePattern, isAppend,
+ isBuffered, policy, strategy, advertiseURI, layout, bufferSize, isFlush);
+ if (manager == null) {
+ return null;
+ }
+
+ manager.initialize();
+
+ return new RollingFileAppender(name, layout, filter, manager, fileName, filePattern,
+ ignoreExceptions, isFlush, isAdvertise ? config.getAdvertiser() : null);
+ }
+}