You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2017/01/17 20:53:58 UTC
[07/32] logging-log4j2 git commit: LOG4J2-1101 - Add documentation.
Add missing license headers
LOG4J2-1101 - Add documentation. Add missing license headers
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8e88deb3
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8e88deb3
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8e88deb3
Branch: refs/heads/LOG4J2-1748and1780-remove-ExecutorService-from-LoggerContext
Commit: 8e88deb3e7e09c5e3df9445d7930bc63b5c39f4b
Parents: acd8a4d
Author: Ralph Goers <rg...@nextiva.com>
Authored: Sun Jan 15 14:13:53 2017 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Jan 15 14:13:53 2017 -0700
----------------------------------------------------------------------
.../rolling/DirectWriteRolloverStrategy.java | 2 +
.../core/appender/rolling/FileExtension.java | 16 ++++
.../core/net/SocketPerformancePreferences.java | 16 ++++
.../logging/log4j/core/CronRolloverApp.java | 16 ++++
.../core/async/Log4j2Jira1688AsyncTest.java | 16 ++++
.../log4j/core/async/Log4j2Jira1688Test.java | 16 ++++
src/changes/changes.xml | 3 +
src/site/xdoc/manual/appenders.xml | 86 +++++++++++++++++++-
8 files changed, 169 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8e88deb3/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java
index 2d8cbc6..6861db2 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java
@@ -46,6 +46,8 @@ import org.apache.logging.log4j.core.util.Integers;
* on the file pattern, however the DirectWriteRolloverStrategy writes directly to a file and does not rename it
* during rollover, except if it is compressed, in which case it will add the appropriate file extension.
* </p>
+ *
+ * @since 2.8
*/
@Plugin(name = "DirectWriteRolloverStrategy", category = Core.CATEGORY_NAME, printObject = true)
public class DirectWriteRolloverStrategy extends AbstractRolloverStrategy implements DirectFileRolloverStrategy {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8e88deb3/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java
index 8a6595e..9d0016f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java
@@ -1,3 +1,19 @@
+/*
+ * 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.rolling;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8e88deb3/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SocketPerformancePreferences.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SocketPerformancePreferences.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SocketPerformancePreferences.java
index c7a246a..571acb6 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SocketPerformancePreferences.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/SocketPerformancePreferences.java
@@ -1,3 +1,19 @@
+/*
+ * 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.net;
import java.net.Socket;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8e88deb3/log4j-core/src/test/java/org/apache/logging/log4j/core/CronRolloverApp.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/CronRolloverApp.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/CronRolloverApp.java
index 7ba7816..59919da 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/CronRolloverApp.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/CronRolloverApp.java
@@ -1,3 +1,19 @@
+/*
+ * 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;
import org.apache.logging.log4j.LogManager;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8e88deb3/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
index 1f98edb..b846d74 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
@@ -1,3 +1,19 @@
+/*
+ * 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.async;
import java.util.Arrays;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8e88deb3/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
index 475addc..57d9247 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
@@ -1,3 +1,19 @@
+/*
+ * 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.async;
import java.util.Arrays;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8e88deb3/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2d51ffe..0020125 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
</properties>
<body>
<release version="2.8" date="2017-MM-DD" description="GA Release 2.8">
+ <action issue="LOG4J2-1101" dev="rgoers" type="add">
+ RollingFileAppender now supports omitting the file name and writing directly to the archive files.
+ </action>
<action issue="LOG4J2-1786" dev="rpopma" type="fix">
ConfigurationScheduler now preserves interrupt flag during stop.
</action>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8e88deb3/src/site/xdoc/manual/appenders.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/appenders.xml b/src/site/xdoc/manual/appenders.xml
index 233bf10..46f0ab8 100644
--- a/src/site/xdoc/manual/appenders.xml
+++ b/src/site/xdoc/manual/appenders.xml
@@ -2378,7 +2378,9 @@ public class JpaLogEntity extends AbstractLogEventWrapperEntity {
be performed while the RolloverStrategy defines how the rollover should be done. If no RolloverStrategy
is configured, RollingFileAppender will use the <a href="#DefaultRolloverStrategy">DefaultRolloverStrategy</a>.
Since log4j-2.5, a <a href="#CustomDeleteOnRollover">custom delete action</a> can be configured in the
- DefaultRolloverStrategy to run at rollover.
+ DefaultRolloverStrategy to run at rollover. Since 2.8 if no file name is configured then
+ <a href="DirectWriteRolloverStrategy">DirectWriteRolloverStrategy</a> will be used instead of
+ DefaultRolloverStrategy.
</p>
<p>
File locking is not supported by the RollingFileAppender.
@@ -2735,7 +2737,38 @@ public class JpaLogEntity extends AbstractLogEventWrapperEntity {
</td>
</tr>
</table>
-
+ <a name="DirectWriteRolloverStrategy"/>
+ <h5>DirectWrite Rollover Strategy</h5>
+ <p>
+ The DirectWriteRolloverStrategy causes log events to be written directly to files represented by the
+ file pattern. With this strategy file renames are not performed. If the size-based triggering policy
+ causes multiple files to be written durring the specified time period they will be numbered starting
+ at one and continually incremented until a time-based rollover occurs.
+ </p>
+ <table>
+ <caption align="top">DirectWriteRolloverStrategy Parameters</caption>
+ <tr>
+ <th>Parameter Name</th>
+ <th>Type</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>maxFiles</td>
+ <td>String</td>
+ <td>The maximum number of files to allow in the time period matching the file pattern. If the
+ number of files is exceeded the oldest file will be deleted. If specified, the value must
+ be greater than 1. If the value is less than zero or omitted then the number of files will
+ not be limited.</td>
+ </tr>
+ <tr>
+ <td>compressionLevel</td>
+ <td>integer</td>
+ <td>
+ Sets the compression level, 0-9, where 0 = none, 1 = best speed, through 9 = best compression.
+ Only implemented for ZIP files.
+ </td>
+ </tr>
+ </table>
<p>
Below is a sample configuration that uses a RollingFileAppender with both the time and size based
triggering policies, will create up to 7 archives on the same day (1-7) that are stored in a directory
@@ -2814,6 +2847,55 @@ public class JpaLogEntity extends AbstractLogEventWrapperEntity {
</Root>
</Loggers>
</Configuration>]]></pre>
+ <p>
+ This sample configuration uses a RollingFileAppender with both the cron and size based
+ triggering policies, and writes directly to an unlimited number of archive files. The cron
+ trigger causes a rollover every hour while the file size is limited to 250MB:
+ </p>
+
+ <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="warn" name="MyApp" packages="">
+ <Appenders>
+ <RollingFile name="RollingFile" filePattern="logs/app-%d{yyyy-MM-dd-HH}-%i.log.gz">
+ <PatternLayout>
+ <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+ </PatternLayout>
+ <Policies>
+ <CronTriggeringPolicy schedule="0 0 * * * ?"/>
+ <SizeBasedTriggeringPolicy size="250 MB"/>
+ </Policies>
+ </RollingFile>
+ </Appenders>
+ <Loggers>
+ <Root level="error">
+ <AppenderRef ref="RollingFile"/>
+ </Root>
+ </Loggers>
+</Configuration>]]></pre>
+ <p>
+ This sample configuration is the same as the previous but limits the number of files saved each hour to 10:
+ </p>
+
+ <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="warn" name="MyApp" packages="">
+ <Appenders>
+ <RollingFile name="RollingFile" filePattern="logs/app-%d{yyyy-MM-dd-HH}-%i.log.gz">
+ <PatternLayout>
+ <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+ </PatternLayout>
+ <Policies>
+ <CronTriggeringPolicy schedule="0 0 * * * ?"/>
+ <SizeBasedTriggeringPolicy size="250 MB"/>
+ </Policies>
+ <DirectWriteRolloverStrategy maxFiles="10"/>
+ </RollingFile>
+ </Appenders>
+ <Loggers>
+ <Root level="error">
+ <AppenderRef ref="RollingFile"/>
+ </Root>
+ </Loggers>
+</Configuration>]]></pre>
<a name="CustomDeleteOnRollover"/>
<h5>Log Archive Retention Policy: Delete on Rollover</h5>
<p>