"Fossies" - the Fresh Open Source Software Archive 
Member "apache-log4j-2.12.4-src/log4j-core/src/test/resources/log4j-rolling-with-custom-delete-script.xml" (20 Dec 2021, 3003 Bytes) of package /linux/misc/apache-log4j-2.12.4-src.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) XML source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17
18 -->
19 <Configuration status="WARN" name="RollingWithCustomDeleteScriptTest">
20 <Properties>
21 <Property name="base">target/rolling-with-delete-script/</Property>
22 </Properties>
23
24 <Appenders>
25 <RollingFile name="RollingFile" fileName="${base}/rollingtest.log"
26 filePattern="${base}/test/test-%i.log">
27 <PatternLayout>
28 <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
29 </PatternLayout>
30 <Policies>
31 <SizeBasedTriggeringPolicy size="50" />
32 </Policies>
33 <DefaultRolloverStrategy max="100" stopCustomActionsOnError="true">
34 <Delete basePath="${base}/test" maxDepth="1" followLinks="false">
35 <ScriptCondition>
36 <Script name="GroovyCondition" language="groovy"><![CDATA[
37 import java.nio.file.*;
38
39 def pattern = ~/test-(\d*)\.log/;
40 assert pattern.getClass() == java.util.regex.Pattern;
41
42 def copy = pathList.collect{it};
43 pathList.each { pathWithAttributes ->
44 def relative = basePath.relativize pathWithAttributes.path
45 def str = relative.toString();
46 statusLogger.trace 'SCRIPT: relative path is ' + str + " (base=$basePath)";
47
48 // keep only files with odd indexes
49
50 def m = pattern.matcher(str);
51 if (m.find()) {
52 def index = m.group(1) as int;
53 def isOdd = (index % 2) == 1;
54 if (isOdd) {
55 copy.remove pathWithAttributes; // remove path with odd index from list to delete
56 statusLogger.trace 'SCRIPT: not deleting path ' + pathWithAttributes;
57 }
58 }
59 }
60 statusLogger.trace 'SCRIPT: returning ' + copy;
61 copy;
62 ]]>
63 </Script>
64 </ScriptCondition>
65 </Delete>
66 </DefaultRolloverStrategy>
67 </RollingFile>
68 </Appenders>
69
70 <Loggers>
71 <Root level="trace">
72 <AppenderRef ref="RollingFile" />
73 </Root>
74 </Loggers>
75
76 </Configuration>