This is an automated email from the ASF dual-hosted git repository.

danwatford pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release18.12 by this push:
     new 58807775e2 Improved: Remove rolled-over log files (OFBIZ-12897)
58807775e2 is described below

commit 58807775e2883ac6c910220ad039e7b5fe9f7c16
Author: Daniel Watford <dan...@watfordconsulting.com>
AuthorDate: Wed Feb 28 13:34:50 2024 +0000

    Improved: Remove rolled-over log files (OFBIZ-12897)
    
    Changed file naming pattern used for rolled over log files in the
    OFBiz default log4j2.xml configuration file such that the date is not
    added to rolled log file names.
    
    Removing the date component from log file names means the RollingFile
    log appender will correctly remove older log files when the maximum
    number of rolled log files is reached.
    
    (cherry picked from commit dee41a3c58436e2dad7f2ce8096902367cececd5)
---
 framework/base/config/log4j2.xml | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/framework/base/config/log4j2.xml b/framework/base/config/log4j2.xml
index 9ee1e20b38..62a10936ed 100644
--- a/framework/base/config/log4j2.xml
+++ b/framework/base/config/log4j2.xml
@@ -19,44 +19,52 @@ under the License.
 -->
 <Configuration monitorInterval="60">
     <!--
-      Default configuration for logging; for customizations refer to 
http://logging.apache.org/log4j/2.x/manual/configuration.html.
+      Default configuration for logging; for customizations refer to
+      http://logging.apache.org/log4j/2.x/manual/configuration.html.
+
       With this configuration the following behavior is defined:
-       * all log messages of severity "warning" or greater, generated by 
external jars, are logged in the ofbiz.log file and in the console
+       * all log messages of severity "warning" or greater, generated by 
external jars, are logged in the ofbiz.log file
+         and in the console
        * all log messages of any severity, generated by OFBiz, are logged in 
the ofbiz.log file and in the console
        * all log messages of severity "error" or greater are also logged in 
the error.log file
-      When the ofbiz.log file reaches 1MB in size a new file is created and a 
date/sequence suffix is added; up to 10 files are kept.
-      When the error.log file reaches 1MB in size a new file is created and a 
date/sequence suffix is added; up to 3 files are kept.
-      The settings in this configuration file can be changed without 
restarting the instance: every 60 seconds the file is checked for modifications.
+
+      Log file ofbiz.log is configured to rollover when it reaches 10MB in 
size, and to keep up to 9 rolled over files.
+      Log file error.log is configured to rollover when it reaches 10MB in 
size, and to keep up to 3 rolled over files.
+
+      The settings in this configuration file can be changed without 
restarting the instance: every 60 seconds the file
+      is checked for modifications.
     -->
     <Appenders>
         <Console name="stdout" target="SYSTEM_OUT">
             <PatternLayout pattern="%date{DEFAULT} |%-20.20thread 
|%-30.30logger{1}|%level{length=1}| %message%n"/>
         </Console>
-        <RollingFile name="ofbiz" fileName="runtime/logs/ofbiz.log"
-                     filePattern="runtime/logs/ofbiz-%d{yyyy-MM-dd}-%i.log">
+
+        <RollingFile name="ofbiz" fileName="runtime/logs/ofbiz.log" 
filePattern="runtime/logs/ofbiz.log.%i">
             <PatternLayout pattern="%date{DEFAULT} |%-20.20thread 
|%-30.30logger{1}|%level{length=1}| %message%n"/>
             <Policies>
-                <TimeBasedTriggeringPolicy/>
-                <SizeBasedTriggeringPolicy size="1 MB"/>
+                <OnStartupTriggeringPolicy/>
+                <SizeBasedTriggeringPolicy size="10 MB"/>
             </Policies>
-            <DefaultRolloverStrategy max="10"/>
+            <DefaultRolloverStrategy fileIndex="min" max="9"/>
         </RollingFile>
-        <RollingFile name="error" fileName="runtime/logs/error.log"
-                     filePattern="runtime/logs/error-%d{yyyy-MM-dd}-%i.log">
+
+        <RollingFile name="error" fileName="runtime/logs/error.log" 
filePattern="runtime/logs/error.log.%i">
             <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
             <PatternLayout pattern="%date{DEFAULT} |%-20.20thread 
|%-30.30logger{1}|%level{length=1}| %message%n"/>
             <Policies>
-                <TimeBasedTriggeringPolicy/>
-                <SizeBasedTriggeringPolicy size="1 MB"/>
+                <OnStartupTriggeringPolicy/>
+                <SizeBasedTriggeringPolicy size="10 MB"/>
             </Policies>
-            <DefaultRolloverStrategy max="3"/>
+            <DefaultRolloverStrategy fileIndex="min" max="3"/>
         </RollingFile>
+
         <Async name="async">
             <AppenderRef ref="ofbiz"/>
             <AppenderRef ref="stdout"/>
             <AppenderRef ref="error"/>
         </Async>
     </Appenders>
+
     <Loggers>
         <logger name="org.apache" level="warn"/>
         <logger name="org.apache.ofbiz" level="all"/>

Reply via email to