logback-dev
Threads by month
- ----- 2025 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
May 2010
- 3 participants
- 63 discussions

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.21-1-g2cec26a
by git-noreply@pixie.qos.ch 12 May '10
by git-noreply@pixie.qos.ch 12 May '10
12 May '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via 2cec26a3063cfa89133cc83e13e07f3c4a2d7746 (commit)
from dbc4e3608b4e351bad6c6c15f7aefe4b6d569554 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=2cec26a3063cfa89133cc83e…
http://github.com/ceki/logback/commit/2cec26a3063cfa89133cc83e13e07f3c4a2d7…
commit 2cec26a3063cfa89133cc83e13e07f3c4a2d7746
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Wed May 12 23:54:43 2010 +0200
- started working on a Groovy configurator called gaffer
diff --git a/logback-access/pom.xml b/logback-access/pom.xml
index 978ff23..e94ff01 100644
--- a/logback-access/pom.xml
+++ b/logback-access/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21</version>
+ <version>0.9.22-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 8fcdb8d..d1a8691 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21</version>
+ <version>0.9.22-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
new file mode 100644
index 0000000..8ba018b
--- /dev/null
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
@@ -0,0 +1,101 @@
+package ch.qos.logback.classic.gaffer;
+
+import ch.qos.logback.core.util.Duration;
+import groovy.lang.Closure;
+
+import java.util.Map
+import ch.qos.logback.core.Context
+import ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter
+import ch.qos.logback.classic.LoggerContext
+import ch.qos.logback.core.spi.ContextAwareImpl
+import ch.qos.logback.core.spi.ContextAwareBase
+import ch.qos.logback.classic.Level
+import ch.qos.logback.classic.Logger
+import ch.qos.logback.core.Appender;
+
+/**
+ * @author Ceki Gücü
+ */
+
+@Mixin(ContextAwareBase)
+public class ConfigurationDelegate {
+
+ List<Appender> appenderList = [];
+
+ void configuration(Closure closure) {
+ configuration([:], closure)
+ }
+
+
+ void configuration(Map map, Closure closure) {
+ processScanAttributes(map.scan, map.scanPeriod);
+ }
+
+ private void processScanAttributes(boolean scan, String scanPeriodStr) {
+ if (scan) {
+ ReconfigureOnChangeFilter rocf = new ReconfigureOnChangeFilter();
+ rocf.setContext(context);
+ if (scanPeriodStr) {
+ try {
+ Duration duration = Duration.valueOf(scanPeriodStr);
+ rocf.setRefreshPeriod(duration.getMilliseconds());
+ addInfo("Setting ReconfigureOnChangeFilter scanning period to "
+ + duration);
+ } catch (NumberFormatException nfe) {
+ addError("Error while converting [" + scanAttrib + "] to long", nfe);
+ }
+ }
+ rocf.start();
+ addInfo("Adding ReconfigureOnChangeFilter as a turbo filter");
+ context.addTurboFilter(rocf);
+ }
+ }
+
+ void root(Level level, List<String> appenderNames = []) {
+ if (level == null) {
+ addError("Root logger cannot be set to level null");
+ } else {
+ logger(org.slf4j.Logger.ROOT_LOGGER_NAME, level, appenderNames);
+ }
+ }
+
+ void logger(String name, Level level, List<String> appenderNames = [], Boolean additivity = null) {
+ if (name) {
+ Logger logger = ((LoggerContext) context).getLogger(name);
+ logger.level = level;
+
+ if (appenderNames) {
+ appenderNames.each { aName ->
+ Appender appender = appenderList.find { it.name == aName };
+ if (appender != null) {
+ logger.addAppender(appender);
+ } else {
+ addError("Failed to find appender named [${it.name}]");
+ }
+ }
+ }
+
+ if (additivity != null) {
+ logger.additive = additivity;
+ }
+ } else {
+ addInfo("No name attribute for logger");
+ }
+ }
+
+ void appender(String name, Class clazz, Closure closure = null) {
+ Appender appender = clazz.newInstance();
+ appender.name = name
+ appender.context = context
+ appenderList.add(appender)
+ if (closure != null) {
+ AppenderDelegate ad = new AppenderDelegate(appender);
+ ad.context = context;
+ closure.delegate = ad;
+ closure.resolveStrategy = Closure.DELEGATE_FIRST
+ closure();
+ }
+ appender.start();
+ }
+}
+
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/Configurator.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/Configurator.groovy
new file mode 100644
index 0000000..9c18e68
--- /dev/null
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/Configurator.groovy
@@ -0,0 +1,49 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.classic.gaffer
+
+class Configurator {
+
+ static void main(String[] args) {
+ runArchitectureRules(new File("src/ch/test/toto.groovy"))
+ }
+
+ static void runArchitectureRules(File dsl) {
+ //LoggerFactory loggerFactory = new LoggerFactory();
+ ConfigurationDelegate configurationDelegate = new ConfigurationDelegate();
+ //AppenderAction appenderAction = new AppenderAction();
+
+
+ Binding binding = new Binding();
+ binding.setProperty("DEBUG", new Integer(1));
+ Script dslScript = new GroovyShell(binding).parse(dsl.text)
+ ExpandoMetaClass emc = new ExpandoMetaClass(dslScript.class, false);
+
+ //configurationDelegate.metaClass.logger = loggerFactory.&logger
+ //configurationDelegate.metaClass.appender = appenderAction.&appender
+
+ emc.configuration = {Closure cl ->
+ println "executing configuration"
+ cl.delegate = configuration
+ cl();
+ }
+
+
+ emc.initialize();
+ dslScript.metaClass = emc;
+
+ dslScript.run()
+ }
+
+}
\ No newline at end of file
diff --git a/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/AppenderDelegate.groovy b/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/AppenderDelegate.groovy
new file mode 100644
index 0000000..3898a41
--- /dev/null
+++ b/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/AppenderDelegate.groovy
@@ -0,0 +1,32 @@
+package ch.qos.logback.classic.gaffer
+
+import ch.qos.logback.core.Appender
+import ch.qos.logback.core.spi.ContextAwareBase
+
+/**
+ * @author Ceki Gücü
+ */
+@Mixin(ContextAwareBase)
+class AppenderDelegate {
+
+ Appender appender;
+
+ AppenderDelegate(Appender appender) {
+ this.appender = appender;
+ }
+
+ void methodMissing(String name, args) {
+ println "method $name accessed"
+ }
+
+ void propertyMissing(String name, def value) {
+ println "-- propertyMissing"
+ if(appender.hasProperty(name)) {
+ //println "-- appender has property $name"
+ appender."${name}" = value;
+ } else {
+ //println "-- appender does not have property [$name]"
+ addError("Appender [${appender.name}] of type [${appender.getClass().canonicalName}] has no [${name}] property " )
+ }
+ }
+}
diff --git a/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegateTest.groovy b/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegateTest.groovy
new file mode 100644
index 0000000..7125a97
--- /dev/null
+++ b/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegateTest.groovy
@@ -0,0 +1,135 @@
+package ch.qos.logback.classic.gaffer
+
+import ch.qos.logback.classic.LoggerContext
+import org.junit.Before
+import org.junit.Test
+import static org.junit.Assert.*
+import ch.qos.logback.core.status.StatusChecker
+import ch.qos.logback.classic.turbo.TurboFilter
+import ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter
+import ch.qos.logback.classic.Level
+import ch.qos.logback.core.testUtil.RandomUtil
+import ch.qos.logback.classic.Logger
+import ch.qos.logback.core.Appender
+import ch.qos.logback.core.helpers.NOPAppender
+import ch.qos.logback.core.ConsoleAppender
+
+/**
+ * @author Ceki Gücü
+ */
+class ConfigurationDelegateTest {
+
+
+ LoggerContext context = new LoggerContext()
+ ConfigurationDelegate configurationDelegate = new ConfigurationDelegate();
+ StatusChecker statusChecker = new StatusChecker(context)
+ int diff = RandomUtil.getPositiveInt();
+
+ @Before
+ void setUp() {
+ context.name = "ConfigurationDelegateTest"
+ configurationDelegate.context = context;
+ }
+
+ @Test
+ void contextAwareMixin() {
+ configurationDelegate.addInfo("smoke")
+ assertTrue(statusChecker.containsMatch("smoke"))
+ }
+
+ @Test
+ void scan() {
+ configurationDelegate.configuration([scan: true, scanPeriod: "10seconds"]) {}
+ assertTrue(statusChecker.containsMatch("Setting ReconfigureOnChangeFilter"))
+ assertTrue(statusChecker.containsMatch("Adding ReconfigureOnChangeFilter as a turbo filter"))
+
+ TurboFilter filter = context.turboFilterList[0]
+ assertTrue(filter instanceof ReconfigureOnChangeFilter)
+ ReconfigureOnChangeFilter rocf = (ReconfigureOnChangeFilter) filter;
+ assertEquals(10 * 1000, rocf.refreshPeriod)
+ }
+
+ @Test
+ void loggerWithoutName() {
+ configurationDelegate.logger("", Level.DEBUG)
+ assertTrue(statusChecker.containsMatch("No name attribute for logger"))
+ }
+
+ @Test
+ void loggerSetLevel() {
+ configurationDelegate.logger("setLevel" + diff, Level.INFO)
+ Logger smokeLogger = context.getLogger("setLevel" + diff);
+ assertEquals(Level.INFO, smokeLogger.level)
+ }
+
+
+ @Test
+ void loggerAppenderRef() {
+ Appender fooAppender = new NOPAppender();
+ fooAppender.name = "FOO"
+ configurationDelegate.appenderList = [fooAppender]
+ configurationDelegate.logger("test" + diff, Level.INFO, ["FOO"])
+ Logger logger = context.getLogger("test" + diff);
+ assertEquals(Level.INFO, logger.level)
+ assertEquals(fooAppender, logger.getAppender("FOO"))
+ }
+
+ @Test
+ void loggerAdditivity() {
+ Appender fooAppender = new NOPAppender();
+ fooAppender.name = "FOO"
+ configurationDelegate.appenderList = [fooAppender]
+ configurationDelegate.logger("test" + diff, Level.INFO, ["FOO"], false)
+ Logger logger = context.getLogger("test" + diff);
+ assertEquals(Level.INFO, logger.level)
+ assertEquals(fooAppender, logger.getAppender("FOO"))
+ assertEquals(false, logger.additive)
+ }
+
+ @Test
+ void loggerAdditivittWithEmptyList() {
+ configurationDelegate.logger("test" + diff, Level.INFO, [], false)
+ Logger logger = context.getLogger("test" + diff);
+ assertEquals(Level.INFO, logger.level)
+ assertEquals(null, logger.getAppender("FOO"))
+ assertEquals(false, logger.additive)
+ }
+
+ @Test
+ void root_LEVEL() {
+ configurationDelegate.root(Level.ERROR)
+ Logger root = context.getLogger(Logger.ROOT_LOGGER_NAME);
+ assertEquals(Level.ERROR, root.level)
+ assertEquals(null, root.getAppender("FOO"))
+ }
+
+ @Test
+ void root_WithList() {
+ Appender fooAppender = new NOPAppender();
+ fooAppender.name = "FOO"
+ configurationDelegate.appenderList = [fooAppender]
+ configurationDelegate.root(Level.WARN, ["FOO"])
+ Logger root = context.getLogger(Logger.ROOT_LOGGER_NAME);
+ assertEquals(Level.WARN, root.level)
+ assertEquals(fooAppender, root.getAppender("FOO"))
+ }
+
+ @Test
+ void appender0() {
+ configurationDelegate.appender("A", NOPAppender);
+ Appender back = configurationDelegate.appenderList.find {it.name = "A"}
+ assertNotNull(back)
+ assertEquals("A", back.name)
+ }
+
+ @Test
+ void appender1() {
+ configurationDelegate.appender("C", ConsoleAppender) {
+ target = "System.err"
+ }
+ Appender back = configurationDelegate.appenderList.find {it.name = "C"}
+ assertNotNull(back)
+ assertEquals("C", back.name)
+ assertEquals("System.err", back.target)
+ }
+}
diff --git a/logback-core/pom.xml b/logback-core/pom.xml
index 62c2eb3..9c96cf3 100644
--- a/logback-core/pom.xml
+++ b/logback-core/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21</version>
+ <version>0.9.22-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -45,6 +45,15 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
+
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+
+
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
@@ -87,6 +96,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
diff --git a/logback-examples/pom.xml b/logback-examples/pom.xml
index e361f49..92b3030 100644
--- a/logback-examples/pom.xml
+++ b/logback-examples/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21</version>
+ <version>0.9.22-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/logback-site/pom.xml b/logback-site/pom.xml
index aadcba1..80f6b58 100644
--- a/logback-site/pom.xml
+++ b/logback-site/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21</version>
+ <version>0.9.22-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/logback-site/src/site/pages/codes.html b/logback-site/src/site/pages/codes.html
index 6ca3d07..27607c5 100644
--- a/logback-site/src/site/pages/codes.html
+++ b/logback-site/src/site/pages/codes.html
@@ -62,47 +62,75 @@
<p class="red bold">from (DEPRECATED)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>testFile.log</file>
- ...
- <layout class="ch.qos.logback.classic.PatternLayout">
- <pattern>%msg%n</pattern>
- </layout>
- </appender> </pre>
+ <file>testFile.log</file>
+ ...
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <pattern>%msg%n</pattern>
+ </layout>
+</appender> </pre>
<p class="red bold">or the shorter equivalent (DEPRECATED)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>testFile.log</file>
- ...
- <!-- layout are assigned the type
- ch.qos.logback.classic.PatternLayout by default -->
- <layout>
- <pattern>%msg%n</pattern>
- </layout>
- </appender> </pre>
+ <file>testFile.log</file>
+ ...
+ <!-- layout are assigned the type ch.qos.logback.classic.PatternLayout by default -->
+ <layout>
+ <pattern>%msg%n</pattern>
+ </layout>
+</appender> </pre>
<p class="green bold">to (GOOD)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>testFile.log</file>
- ...
- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <pattern>%msg%n</pattern>
- </encode>
- </appender> </pre>
+ <file>testFile.log</file>
+ ...
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <pattern>%msg%n</pattern>
+ </encode>
+</appender> </pre>
<p class="green bold">or the shorter equivalent (GOOD)</p>
<pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>testFile.log</file>
- ...
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%msg%n</pattern>
- </encode>
- </appender> </pre>
+ <file>testFile.log</file>
+ ...
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%msg%n</pattern>
+ </encode>
+</appender> </pre>
+
+
+ <p>For layout type other than <code>PatternLayout</code>, for
+ example <code>HTMLLayout</code>, your configuration files need to be
+ changed
+ </p>
+ <p class="red bold">from (DEPRECATED)</p>
+
+ <pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>testFile.log</file>
+ ...
+ <layout class="ch.qos.logback.classic.html.HTMLLayout">
+ <pattern>%msg%n</pattern>
+ </layout>
+</appender> </pre>
+
+
+ <p class="green bold">to (GOOD)</p>
+ <pre class="prettyprint source"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>testFile.log</file>
+ ...
+ <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
+ <layout class="ch.qos.logback.classic.html.HTMLLayout">
+ <pattern>%msg%n</pattern>
+ </layout>
+ </encoder>
+</appender> </pre>
+
+
<p>We hope to make up for this inconvenience with cool new features
which are only possible using encoders. <b>During a transition
diff --git a/logback-site/src/site/pages/css/popup.css b/logback-site/src/site/pages/css/popup.css
new file mode 100644
index 0000000..2b20468
--- /dev/null
+++ b/logback-site/src/site/pages/css/popup.css
@@ -0,0 +1,67 @@
+
+/* =========== popup ================== */
+#backgroundPopup {
+ display:none;
+ position:fixed;
+ _position:absolute; /* hack for internet explorer 6*/
+ height:100%;
+ width:100%;
+ top:0;
+ left:0;
+ background:#000000;
+ border:1px solid #cecece;
+ z-index:1;
+}
+
+#popupContents {
+ display:none;
+ position:fixed;
+ _position:absolute; /* hack for internet explorer 6*/
+ height: 150px;
+ width: 408px;
+ background:#FFFFFF;
+ border: 2px solid #cecece;
+ z-index:2;
+ padding-left: 1ex;
+ font-size:13px;
+}
+
+#popupContents p {
+ margin: 0px;
+}
+#popupContents h3 {
+ margin: 0px;
+}
+
+#popupContactClose {
+ font-size:14px;
+ line-height:14px;
+ right:6px;
+ top:4px;
+ position:absolute;
+ color:#6fa5fd;
+ font-weight:700;
+ display:block;
+}
+
+a.popupLink {
+ background: #FFF;
+ color: #0079C5;
+ font-family: "Comic Sans MS", sans-serif;
+ white-space: nowrap;
+ font-size: 14px;
+ font-weight: bold;
+
+ border-top: 2px solid #DDD;
+ border-left: 2px solid #DDD;
+ border-right: 2px solid #888;
+ border-bottom: 2px solid #888;
+ padding: 0px 1em 0px 1em;
+ margin: 0px 0px 3px 0px;
+}
+
+a.popupLink:hover {
+ background: #E0E0EF;
+ cursor: pointer;
+}
+
diff --git a/logback-site/src/site/pages/download.html b/logback-site/src/site/pages/download.html
index dc7bc51..6d5c460 100644
--- a/logback-site/src/site/pages/download.html
+++ b/logback-site/src/site/pages/download.html
@@ -8,15 +8,37 @@
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/screen.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/_print.css" media="print" />
+ <link rel="stylesheet" type="text/css" href="css/popup.css" media="screen" />
</head>
- <body>
- <script type="text/javascript">prefix='';</script>
+ <body onload="centerPopup(); loadPopup();">
+ <script type="text/javascript">prefix='';</script>
+
+ <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" ></script>
+ <script type="text/javascript" src="js/jquery.cookies.2.2.0.js"></script>
+ <script type="text/javascript" src="js/popup.js" ></script>
<script src="templates/header.js" type="text/javascript"></script>
+
<div id="left">
<noscript>Please turn on Javascript to view this menu</noscript>
<script src="templates/left.js" type="text/javascript"></script>
</div>
+
+ <div id="popupContents">
+ <br/>
+ <h3>Would you like to participate in our one-question survey?</h3>
+
+ <br/>
+ <table width="100%">
+ <tr>
+ <td><a class="popupLink" id="announce">Yes, take me to the survey.</a></td>
+ <td><a class="popupLink" id="popupContentsClose">No, thanks.</a></td>
+ </tr>
+ </table>
+ </div>
+ <div id="backgroundPopup"></div>
+
+
<div id="content">
<h2>Download links</h2>
diff --git a/logback-site/src/site/pages/js/jquery.cookies.2.2.0.js b/logback-site/src/site/pages/js/jquery.cookies.2.2.0.js
new file mode 100644
index 0000000..c6dec07
--- /dev/null
+++ b/logback-site/src/site/pages/js/jquery.cookies.2.2.0.js
@@ -0,0 +1,450 @@
+/**
+ * Copyright (c) 2005 - 2010, James Auldridge
+ * All rights reserved.
+ *
+ * Licensed under the BSD, MIT, and GPL (your choice!) Licenses:
+ * http://code.google.com/p/cookies/wiki/License
+ *
+ */
+var jaaulde = window.jaaulde || {};
+jaaulde.utils = jaaulde.utils || {};
+jaaulde.utils.cookies = ( function()
+{
+ var resolveOptions, assembleOptionsString, parseCookies, constructor, defaultOptions = {
+ expiresAt: null,
+ path: '/',
+ domain: null,
+ secure: false
+ };
+ /**
+ * resolveOptions - receive an options object and ensure all options are present and valid, replacing with defaults where necessary
+ *
+ * @access private
+ * @static
+ * @parameter Object options - optional options to start with
+ * @return Object complete and valid options object
+ */
+ resolveOptions = function( options )
+ {
+ var returnValue, expireDate;
+
+ if( typeof options !== 'object' || options === null )
+ {
+ returnValue = defaultOptions;
+ }
+ else
+ {
+ returnValue = {
+ expiresAt: defaultOptions.expiresAt,
+ path: defaultOptions.path,
+ domain: defaultOptions.domain,
+ secure: defaultOptions.secure
+ };
+
+ if( typeof options.expiresAt === 'object' && options.expiresAt instanceof Date )
+ {
+ returnValue.expiresAt = options.expiresAt;
+ }
+ else if( typeof options.hoursToLive === 'number' && options.hoursToLive !== 0 )
+ {
+ expireDate = new Date();
+ expireDate.setTime( expireDate.getTime() + ( options.hoursToLive * 60 * 60 * 1000 ) );
+ returnValue.expiresAt = expireDate;
+ }
+
+ if( typeof options.path === 'string' && options.path !== '' )
+ {
+ returnValue.path = options.path;
+ }
+
+ if( typeof options.domain === 'string' && options.domain !== '' )
+ {
+ returnValue.domain = options.domain;
+ }
+
+ if( options.secure === true )
+ {
+ returnValue.secure = options.secure;
+ }
+ }
+
+ return returnValue;
+ };
+ /**
+ * assembleOptionsString - analyze options and assemble appropriate string for setting a cookie with those options
+ *
+ * @access private
+ * @static
+ * @parameter options OBJECT - optional options to start with
+ * @return STRING - complete and valid cookie setting options
+ */
+ assembleOptionsString = function( options )
+ {
+ options = resolveOptions( options );
+
+ return (
+ ( typeof options.expiresAt === 'object' && options.expiresAt instanceof Date ? '; expires=' + options.expiresAt.toGMTString() : '' ) +
+ '; path=' + options.path +
+ ( typeof options.domain === 'string' ? '; domain=' + options.domain : '' ) +
+ ( options.secure === true ? '; secure' : '' )
+ );
+ };
+ /**
+ * parseCookies - retrieve document.cookie string and break it into a hash with values decoded and unserialized
+ *
+ * @access private
+ * @static
+ * @return OBJECT - hash of cookies from document.cookie
+ */
+ parseCookies = function()
+ {
+ var cookies = {}, i, pair, name, value, separated = document.cookie.split( ';' ), unparsedValue;
+ for( i = 0; i < separated.length; i = i + 1 )
+ {
+ pair = separated[i].split( '=' );
+ name = pair[0].replace( /^\s*/, '' ).replace( /\s*$/, '' );
+
+ try
+ {
+ value = decodeURIComponent( pair[1] );
+ }
+ catch( e1 )
+ {
+ value = pair[1];
+ }
+
+ if( typeof JSON === 'object' && JSON !== null && typeof JSON.parse === 'function' )
+ {
+ try
+ {
+ unparsedValue = value;
+ value = JSON.parse( value );
+ }
+ catch( e2 )
+ {
+ value = unparsedValue;
+ }
+ }
+
+ cookies[name] = value;
+ }
+ return cookies;
+ };
+
+ constructor = function(){};
+
+ /**
+ * get - get one, several, or all cookies
+ *
+ * @access public
+ * @paramater Mixed cookieName - String:name of single cookie; Array:list of multiple cookie names; Void (no param):if you want all cookies
+ * @return Mixed - Value of cookie as set; Null:if only one cookie is requested and is not found; Object:hash of multiple or all cookies (if multiple or all requested);
+ */
+ constructor.prototype.get = function( cookieName )
+ {
+ var returnValue, item, cookies = parseCookies();
+
+ if( typeof cookieName === 'string' )
+ {
+ returnValue = ( typeof cookies[cookieName] !== 'undefined' ) ? cookies[cookieName] : null;
+ }
+ else if( typeof cookieName === 'object' && cookieName !== null )
+ {
+ returnValue = {};
+ for( item in cookieName )
+ {
+ if( typeof cookies[cookieName[item]] !== 'undefined' )
+ {
+ returnValue[cookieName[item]] = cookies[cookieName[item]];
+ }
+ else
+ {
+ returnValue[cookieName[item]] = null;
+ }
+ }
+ }
+ else
+ {
+ returnValue = cookies;
+ }
+
+ return returnValue;
+ };
+ /**
+ * filter - get array of cookies whose names match the provided RegExp
+ *
+ * @access public
+ * @paramater Object RegExp - The regular expression to match against cookie names
+ * @return Mixed - Object:hash of cookies whose names match the RegExp
+ */
+ constructor.prototype.filter = function( cookieNameRegExp )
+ {
+ var cookieName, returnValue = {}, cookies = parseCookies();
+
+ if( typeof cookieNameRegExp === 'string' )
+ {
+ cookieNameRegExp = new RegExp( cookieNameRegExp );
+ }
+
+ for( cookieName in cookies )
+ {
+ if( cookieName.match( cookieNameRegExp ) )
+ {
+ returnValue[cookieName] = cookies[cookieName];
+ }
+ }
+
+ return returnValue;
+ };
+ /**
+ * set - set or delete a cookie with desired options
+ *
+ * @access public
+ * @paramater String cookieName - name of cookie to set
+ * @paramater Mixed value - Any JS value. If not a string, will be JSON encoded; NULL to delete
+ * @paramater Object options - optional list of cookie options to specify
+ * @return void
+ */
+ constructor.prototype.set = function( cookieName, value, options )
+ {
+ if( typeof options !== 'object' || options === null )
+ {
+ options = {};
+ }
+
+ if( typeof value === 'undefined' || value === null )
+ {
+ value = '';
+ options.hoursToLive = -8760;
+ }
+
+ else if( typeof value !== 'string' )
+ {
+ if( typeof JSON === 'object' && JSON !== null && typeof JSON.stringify === 'function' )
+ {
+ value = JSON.stringify( value );
+ }
+ else
+ {
+ throw new Error( 'cookies.set() received non-string value and could not serialize.' );
+ }
+ }
+
+
+ var optionsString = assembleOptionsString( options );
+
+ document.cookie = cookieName + '=' + encodeURIComponent( value ) + optionsString;
+ };
+ /**
+ * del - delete a cookie (domain and path options must match those with which the cookie was set; this is really an alias for set() with parameters simplified for this use)
+ *
+ * @access public
+ * @paramater MIxed cookieName - String name of cookie to delete, or Bool true to delete all
+ * @paramater Object options - optional list of cookie options to specify ( path, domain )
+ * @return void
+ */
+ constructor.prototype.del = function( cookieName, options )
+ {
+ var allCookies = {}, name;
+
+ if( typeof options !== 'object' || options === null )
+ {
+ options = {};
+ }
+
+ if( typeof cookieName === 'boolean' && cookieName === true )
+ {
+ allCookies = this.get();
+ }
+ else if( typeof cookieName === 'string' )
+ {
+ allCookies[cookieName] = true;
+ }
+
+ for( name in allCookies )
+ {
+ if( typeof name === 'string' && name !== '' )
+ {
+ this.set( name, null, options );
+ }
+ }
+ };
+ /**
+ * test - test whether the browser is accepting cookies
+ *
+ * @access public
+ * @return Boolean
+ */
+ constructor.prototype.test = function()
+ {
+ var returnValue = false, testName = 'cT', testValue = 'data';
+
+ this.set( testName, testValue );
+
+ if( this.get( testName ) === testValue )
+ {
+ this.del( testName );
+ returnValue = true;
+ }
+
+ return returnValue;
+ };
+ /**
+ * setOptions - set default options for calls to cookie methods
+ *
+ * @access public
+ * @param Object options - list of cookie options to specify
+ * @return void
+ */
+ constructor.prototype.setOptions = function( options )
+ {
+ if( typeof options !== 'object' )
+ {
+ options = null;
+ }
+
+ defaultOptions = resolveOptions( options );
+ };
+
+ return new constructor();
+} )();
+
+( function()
+{
+ if( window.jQuery )
+ {
+ ( function( $ )
+ {
+ $.cookies = jaaulde.utils.cookies;
+
+ var extensions = {
+ /**
+ * $( 'selector' ).cookify - set the value of an input field, or the innerHTML of an element, to a cookie by the name or id of the field or element
+ * (field or element MUST have name or id attribute)
+ *
+ * @access public
+ * @param options OBJECT - list of cookie options to specify
+ * @return jQuery
+ */
+ cookify: function( options )
+ {
+ return this.each( function()
+ {
+ var i, nameAttrs = ['name', 'id'], name, $this = $( this ), value;
+
+ for( i in nameAttrs )
+ {
+ if( ! isNaN( i ) )
+ {
+ name = $this.attr( nameAttrs[ i ] );
+ if( typeof name === 'string' && name !== '' )
+ {
+ if( $this.is( ':checkbox, :radio' ) )
+ {
+ if( $this.attr( 'checked' ) )
+ {
+ value = $this.val();
+ }
+ }
+ else if( $this.is( ':input' ) )
+ {
+ value = $this.val();
+ }
+ else
+ {
+ value = $this.html();
+ }
+
+ if( typeof value !== 'string' || value === '' )
+ {
+ value = null;
+ }
+
+ $.cookies.set( name, value, options );
+
+ break;
+ }
+ }
+ }
+ } );
+ },
+ /**
+ * $( 'selector' ).cookieFill - set the value of an input field or the innerHTML of an element from a cookie by the name or id of the field or element
+ *
+ * @access public
+ * @return jQuery
+ */
+ cookieFill: function()
+ {
+ return this.each( function()
+ {
+ var n, getN, nameAttrs = ['name', 'id'], name, $this = $( this ), value;
+
+ getN = function()
+ {
+ n = nameAttrs.pop();
+ return !! n;
+ };
+
+ while( getN() )
+ {
+ name = $this.attr( n );
+ if( typeof name === 'string' && name !== '' )
+ {
+ value = $.cookies.get( name );
+ if( value !== null )
+ {
+ if( $this.is( ':checkbox, :radio' ) )
+ {
+ if( $this.val() === value )
+ {
+ $this.attr( 'checked', 'checked' );
+ }
+ else
+ {
+ $this.removeAttr( 'checked' );
+ }
+ }
+ else if( $this.is( ':input' ) )
+ {
+ $this.val( value );
+ }
+ else
+ {
+ $this.html( value );
+ }
+ }
+
+ break;
+ }
+ }
+ } );
+ },
+ /**
+ * $( 'selector' ).cookieBind - call cookie fill on matching elements, and bind their change events to cookify()
+ *
+ * @access public
+ * @param options OBJECT - list of cookie options to specify
+ * @return jQuery
+ */
+ cookieBind: function( options )
+ {
+ return this.each( function()
+ {
+ var $this = $( this );
+ $this.cookieFill().change( function()
+ {
+ $this.cookify( options );
+ } );
+ } );
+ }
+ };
+
+ $.each( extensions, function( i )
+ {
+ $.fn[i] = this;
+ } );
+
+ } )( window.jQuery );
+ }
+} )();
\ No newline at end of file
diff --git a/logback-site/src/site/pages/js/popup.js b/logback-site/src/site/pages/js/popup.js
new file mode 100644
index 0000000..e57d4b9
--- /dev/null
+++ b/logback-site/src/site/pages/js/popup.js
@@ -0,0 +1,102 @@
+/***************************/
+//@Author: Adrian "yEnS" Mato Gondelle
+//@website: www.yensdesign.com
+//@email: yensamg(a)gmail.com
+//@license: Feel free to use it, but keep this credits please!
+/***************************/
+
+//SETTING UP OUR POPUP
+//0 means disabled; 1 means enabled;
+var popupStatus = 0;
+
+//loading popup with jQuery magic!
+function loadPopup() {
+ var surveyCookie = $.cookies.get("SURVEY");
+ if(surveyCookie) {
+ popupStatus = 0;
+ return;
+ }
+ //loads popup only if it is disabled
+ if(popupStatus==0){
+ $("#backgroundPopup").css({
+ "opacity": "0.7"
+ });
+ $("#backgroundPopup").fadeIn("slow");
+ $("#popupContents").fadeIn("slow");
+ popupStatus = 1;
+ }
+}
+
+function getDateInSixMonths() {
+ var date = new Date();
+ date.setDate(date.getDate()+180);
+ return date;
+}
+
+//disabling popup with jQuery magic!
+function disablePopup(){
+ //disables popup only if it is enabled
+ if(popupStatus==1){
+ $("#backgroundPopup").fadeOut("slow");
+ $("#popupContents").fadeOut("slow");
+ popupStatus = 0;
+ $.cookies.set("SURVEY", "NO", {expiresAt: getDateInSixMonths()});
+ }
+}
+
+//centering popup
+function centerPopup(){
+ //request data for centering
+ var windowWidth = document.documentElement.clientWidth;
+ var windowHeight = document.documentElement.clientHeight;
+ var popupHeight = $("#popupContents").height();
+ var popupWidth = $("#popupContents").width();
+ //centering
+ $("#popupContents").css({
+ "position": "absolute",
+ "top": windowHeight/2-popupHeight/2,
+ "left": windowWidth/2-popupWidth/2
+ });
+ //only need force for IE6
+
+ $("#backgroundPopup").css({
+ "height": windowHeight
+ });
+
+}
+
+
+//CONTROLLING EVENTS IN jQuery
+$(document).ready(function(){
+
+ //LOADING POPUP
+ //Click the button event!
+ $("#button").click(function(){
+ //centering with css
+ centerPopup();
+ //load popup
+ loadPopup();
+ });
+
+ //CLOSING POPUP
+ //Click the x event!
+ $("#popupContentsClose").click(function(){
+ disablePopup();
+ });
+ //Click out event!
+ $("#backgroundPopup").click(function(){
+ //disablePopup();
+ });
+ //Press Escape event!
+ $(document).keypress(function(e){
+ if(e.keyCode==27 && popupStatus==1){
+ disablePopup();
+ }
+ });
+
+ $("#announce").click(function(){
+ $.cookies.set("SURVEY", "YES", {expiresAt: getDateInSixMonths()});
+ window.location='http://ceki.questionform.com/public/logbackDSL';
+ });
+});
+
diff --git a/logback-site/src/site/pages/reasonsToSwitch.html b/logback-site/src/site/pages/reasonsToSwitch.html
index 20c29bd..b12bf23 100644
--- a/logback-site/src/site/pages/reasonsToSwitch.html
+++ b/logback-site/src/site/pages/reasonsToSwitch.html
@@ -100,7 +100,7 @@
</p>
<h3><a name="conditional" href="#conditional">Conditional
- prcessing of configuration files</a></h3>
+ processing of configuration files</a></h3>
<p>Developers often need to juggle between several logback
configuration files targeting different environments such as
diff --git a/pom.xml b/pom.xml
index b804305..b77610a 100755
--- a/pom.xml
+++ b/pom.xml
@@ -1,11 +1,12 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21</version>
+ <version>0.9.22-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Logback-Parent</name>
diff --git a/release.sh b/release.sh
index 1fa6637..44b5eb8 100644
--- a/release.sh
+++ b/release.sh
@@ -1,6 +1,6 @@
# memory aid
-mvn versions:set -DnewVersion=${VERSION_NUMBER}
+mvn versions:set -DnewVersion=${VERSION_NUMBER} -DgenerateBackupPoms=false
mvn clean
mvn install
-----------------------------------------------------------------------
Summary of changes:
logback-access/pom.xml | 2 +-
logback-classic/pom.xml | 2 +-
.../classic/gaffer/ConfigurationDelegate.groovy | 101 +++++
.../qos/logback/classic/gaffer/Configurator.groovy | 49 +++
.../logback/classic/gaffer/AppenderDelegate.groovy | 32 ++
.../gaffer/ConfigurationDelegateTest.groovy | 135 ++++++
logback-core/pom.xml | 20 +-
logback-examples/pom.xml | 2 +-
logback-site/pom.xml | 2 +-
logback-site/src/site/pages/codes.html | 84 +++--
logback-site/src/site/pages/css/popup.css | 67 +++
logback-site/src/site/pages/download.html | 26 +-
.../src/site/pages/js/jquery.cookies.2.2.0.js | 450 ++++++++++++++++++++
logback-site/src/site/pages/js/popup.js | 102 +++++
logback-site/src/site/pages/reasonsToSwitch.html | 2 +-
pom.xml | 5 +-
release.sh | 2 +-
17 files changed, 1044 insertions(+), 39 deletions(-)
create mode 100644 logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
create mode 100644 logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/Configurator.groovy
create mode 100644 logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/AppenderDelegate.groovy
create mode 100644 logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegateTest.groovy
create mode 100644 logback-site/src/site/pages/css/popup.css
create mode 100644 logback-site/src/site/pages/js/jquery.cookies.2.2.0.js
create mode 100644 logback-site/src/site/pages/js/popup.js
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[JIRA] Created: (LBCLASSIC-209) Allow configuration via properties file in addition to XML (logback.xml)
by Alvin Chee (JIRA) 11 May '10
by Alvin Chee (JIRA) 11 May '10
11 May '10
Allow configuration via properties file in addition to XML (logback.xml)
------------------------------------------------------------------------
Key: LBCLASSIC-209
URL: http://jira.qos.ch/browse/LBCLASSIC-209
Project: logback-classic
Issue Type: New Feature
Reporter: Alvin Chee
Assignee: Logback dev list
log4j supports both properties and xml configuration. It would be great if logback has this feature as well.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
3
5

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.21
by git-noreply@pixie.qos.ch 08 May '10
by git-noreply@pixie.qos.ch 08 May '10
08 May '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via dbc4e3608b4e351bad6c6c15f7aefe4b6d569554 (commit)
from 729c58c5a6be3022f463a3f66e15eb70939eacdf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=dbc4e3608b4e351bad6c6c15…
http://github.com/ceki/logback/commit/dbc4e3608b4e351bad6c6c15f7aefe4b6d569…
commit dbc4e3608b4e351bad6c6c15f7aefe4b6d569554
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Sat May 8 18:58:09 2010 +0200
- preparing release 0.9.21
diff --git a/logback-access/pom.xml b/logback-access/pom.xml
index cf3f201..978ff23 100644
--- a/logback-access/pom.xml
+++ b/logback-access/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21-SNAPSHOT</version>
+ <version>0.9.21</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 045663f..8fcdb8d 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21-SNAPSHOT</version>
+ <version>0.9.21</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/logback-core/pom.xml b/logback-core/pom.xml
index ed14166..62c2eb3 100644
--- a/logback-core/pom.xml
+++ b/logback-core/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21-SNAPSHOT</version>
+ <version>0.9.21</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/logback-examples/pom.xml b/logback-examples/pom.xml
index 841e3b1..e361f49 100644
--- a/logback-examples/pom.xml
+++ b/logback-examples/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21-SNAPSHOT</version>
+ <version>0.9.21</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/logback-site/pom.xml b/logback-site/pom.xml
index 359591c..aadcba1 100644
--- a/logback-site/pom.xml
+++ b/logback-site/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21-SNAPSHOT</version>
+ <version>0.9.21</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 7689704..0df0912 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -28,7 +28,7 @@
<hr width="80%" align="center" />
- <h3>April xx, 2010 - Release of version 0.9.21</h3>
+ <h3>May 8th, 2010 - Release of version 0.9.21</h3>
<p>SLF4J dependency upgraded to 1.6.0</p>
@@ -46,7 +46,9 @@
<p>Fixed rollover problem occuring when the target directory was
missing as reported in <a
href="http://jira.qos.ch/browse/LBCORE-151">LBCORE-151</a> by
- Torsten Juergeleit.
+ Torsten Juergeleit. A closely related problem was reported in <a
+ href="http://jira.qos.ch/browse/LBCLASSIC-167">LBCLASSIC-167</a>
+ by Rick Janda.
</p>
diff --git a/pom.xml b/pom.xml
index 788d523..b804305 100755
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>0.9.21-SNAPSHOT</version>
+ <version>0.9.21</version>
<packaging>pom</packaging>
<name>Logback-Parent</name>
-----------------------------------------------------------------------
Summary of changes:
logback-access/pom.xml | 2 +-
logback-classic/pom.xml | 2 +-
logback-core/pom.xml | 2 +-
logback-examples/pom.xml | 2 +-
logback-site/pom.xml | 2 +-
logback-site/src/site/pages/news.html | 6 ++++--
pom.xml | 2 +-
7 files changed, 10 insertions(+), 8 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. annotated tag, v_0.9.21, created. v_0.9.21
by git-noreply@pixie.qos.ch 08 May '10
by git-noreply@pixie.qos.ch 08 May '10
08 May '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The annotated tag, v_0.9.21 has been created
at d383758f0fa90cf85851483c539b224b5e4609ca (tag)
tagging dbc4e3608b4e351bad6c6c15f7aefe4b6d569554 (commit)
replaces v0.9.20
tagged by Ceki Gulcu
on Sun May 9 01:14:55 2010 +0200
- Log -----------------------------------------------------------------
tagging v0.9.21
Ceki Gulcu (15):
started working on 0.9.21-SNAPSHOT
It looks like Windows XP may also throw an IOException instead of
Removed superflous import
minor edits
- Minor edits
identidied syncronization prroblem in SiftingAppenderBase as shown by
- Fixed http://jira.qos.ch/browse/LBCLASSIC-204
added link to Shibboleth
- typo corrections
- upgrade to SLF4J 1.6.0-RC0
news update
- upgrade to SLF4J 1.6.0-alpha2
- upgrade to SLF4J 1.6.0
- fixed http://jira.qos.ch/browse/LBCORE-151
- preparing release 0.9.21
-----------------------------------------------------------------------
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0
Hello all,
I am happy to announce the immediate availability of logback version
0.9.21. In addition to bug fixes and alignment with SLF4J 1.6.0, this
version introduces GEventEvaluator which can process boolean
expressions written in Groovy.
Please refer to the the news page for precise details.
http://logback.qos.ch/news.html
You can download logback, including full source code, class files and
documentation on our download page, shown below.
http://logback.qos.ch/download.html
You can receive logback related announcements by subscribing to the
QOS.ch announce mailing list. To subscribe to QOS.ch announce list,
please visit the following URL.
http://www.qos.ch/mailman/listinfo/announce
--
Ceki
1
0

[JIRA] Created: (LBCLASSIC-167) RollingFileAppender does not auto create subdirectories in some circumstances
by Rick Janda (JIRA) 08 May '10
by Rick Janda (JIRA) 08 May '10
08 May '10
RollingFileAppender does not auto create subdirectories in some circumstances
-----------------------------------------------------------------------------
Key: LBCLASSIC-167
URL: http://jira.qos.ch/browse/LBCLASSIC-167
Project: logback-classic
Issue Type: Bug
Components: appender
Affects Versions: 0.917
Reporter: Rick Janda
Assignee: Logback dev list
If the FileNamePattern of the rollingPolicy contains another directory than the File element of the appender, than the directory in the FileNamePattern is not created automatically.
The OnConsoleErrorListener writes out the following error in this case:
-ERROR in c.q.l.core.rolling.helper.Compress - Error occurred while compressing [/opt/baa-logserver/logs/logback.log33794048136194907.tmp] into [/opt/baa-logserver/logs/archive/logback_2009-10-26.log.zip]. java.io.FileNotFoundException: /opt/baa-logserver/logs/archive/logback_2009-10-26.log.zip (No such file or directory)
at java.io.FileNotFoundException: /opt/baa-logserver/logs/archive/logback_2009-10-26.log.zip (No such file or directory)
The appender is configured as followed (files are rolled into a archive directory on daily basis):
<appender name="LOGBACK" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${LOG_DIR}/logback.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${LOG_DIR}/archive/logback_%d{yyyy-MM-dd}.log.zip</FileNamePattern>
<MaxHistory>${MAX_HISTORY_DAYS}</MaxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date{dd-MM-yyyy HH:mm:ss.SSS} [%contextName] \(%mdc{refId}\) %-5level %logger{0} - %msg%n%xEx{full}</Pattern>
</layout>
</appender>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
3
3

[JIRA] Created: (LBCORE-151) RenameUtil doesn't create create a non-existing destination directory
by Torsten Juergeleit (JIRA) 08 May '10
by Torsten Juergeleit (JIRA) 08 May '10
08 May '10
RenameUtil doesn't create create a non-existing destination directory
---------------------------------------------------------------------
Key: LBCORE-151
URL: http://jira.qos.ch/browse/LBCORE-151
Project: logback-core
Issue Type: Bug
Components: Rolling
Affects Versions: 0.9.20
Reporter: Torsten Juergeleit
Assignee: Logback dev list
RenameUtil doesn't handle moving files into non-existing directories in a robust manner. There's no check if the destination directory is available and writable.
If File.renameTo() fails then it's assumed that this is due to a locked from file. The other reason of a non-existing or non-writable destination directory is not checked (corresponding unit test is attached).
Here it makes sense to create a non-existing directory tree via File.mkdirs().
Otherwise the requirement of an existing destination directory should be clearly stated in the documentation of RollingFileAppender.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
2
5

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.20-14-g729c58c
by git-noreply@pixie.qos.ch 08 May '10
by git-noreply@pixie.qos.ch 08 May '10
08 May '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via 729c58c5a6be3022f463a3f66e15eb70939eacdf (commit)
via cbd336b71ef1842babf7ccdcf59e63861beef0ab (commit)
from 5e93537ed06b334bd3f57f577f0545d598caae13 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=729c58c5a6be3022f463a3f6…
http://github.com/ceki/logback/commit/729c58c5a6be3022f463a3f66e15eb70939ea…
commit 729c58c5a6be3022f463a3f66e15eb70939eacdf
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Sat May 8 18:45:21 2010 +0200
- fixed http://jira.qos.ch/browse/LBCORE-151
- removed previoulsy deprecated getFirstFilter() method in
FilterAttachable interface
diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
index b194050..d4a624a 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
@@ -248,7 +248,4 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
return fai.getFilterChainDecision(event);
}
- public Filter getFirstFilter() {
- return fai.getFirstFilter();
- }
}
diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogImpl.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogImpl.java
index 35bd8ce..95742fa 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogImpl.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogImpl.java
@@ -249,8 +249,4 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
public FilterReply getFilterChainDecision(AccessEvent event) {
return fai.getFilterChainDecision(event);
}
-
- public Filter getFirstFilter() {
- return fai.getFirstFilter();
- }
}
\ No newline at end of file
diff --git a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java
index 2c55c6e..a8a3069 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/spi/AccessContext.java
@@ -84,8 +84,4 @@ public class AccessContext extends ContextBase implements
public FilterReply getFilterChainDecision(AccessEvent event) {
return fai.getFilterChainDecision(event);
}
-
- public Filter<AccessEvent> getFirstFilter() {
- return fai.getFirstFilter();
- }
}
diff --git a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java b/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
index d19ddbb..dc84dec 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
@@ -241,10 +241,6 @@ public class LogbackValve extends ValveBase implements Lifecycle, Context,
fai.addFilter(newFilter);
}
- public Filter getFirstFilter() {
- return fai.getFirstFilter();
- }
-
public void clearAllFilters() {
fai.clearAllFilters();
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java
index f25d981..7c6ec36 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/rolling/TimeBasedRollingWithConfigFileTest.java
@@ -34,7 +34,7 @@ import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
import ch.qos.logback.core.status.StatusChecker;
public class TimeBasedRollingWithConfigFileTest extends
- ScaffoldingForRollingTests {
+ ScaffoldingForRollingTests {
LoggerContext lc = new LoggerContext();
Logger logger = lc.getLogger(this.getClass());
@@ -67,7 +67,7 @@ public class TimeBasedRollingWithConfigFileTest extends
String testId = "basic";
lc.putProperty("testId", testId);
loadConfig(ClassicTestConstants.JORAN_INPUT_PREFIX + "rolling/" + testId
- + ".xml");
+ + ".xml");
StatusChecker sc = new StatusChecker(lc);
assertTrue(sc.isErrorFree());
@@ -76,18 +76,18 @@ public class TimeBasedRollingWithConfigFileTest extends
expectedFilenameList.add(randomOutputDir + "z" + testId);
RollingFileAppender<ILoggingEvent> rfa = (RollingFileAppender<ILoggingEvent>) root
- .getAppender("ROLLING");
+ .getAppender("ROLLING");
TimeBasedRollingPolicy tprp = (TimeBasedRollingPolicy<ILoggingEvent>) rfa
- .getTriggeringPolicy();
+ .getTriggeringPolicy();
TimeBasedFileNamingAndTriggeringPolicy tbnatp = tprp
- .getTimeBasedFileNamingAndTriggeringPolicy();
+ .getTimeBasedFileNamingAndTriggeringPolicy();
String prefix = "Hello---";
int runLength = 4;
for (int i = 0; i < runLength; i++) {
logger.debug(prefix + i);
- addExpectedFileNamedIfItsTime_ByDate(testId, false);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
incCurrentTime(500);
tbnatp.setCurrentTime(currentTime);
}
@@ -108,21 +108,21 @@ public class TimeBasedRollingWithConfigFileTest extends
sizeThreshold = prefix.length() * approxWritesPerPeriod;
lc.putProperty("sizeThreshold", "" + sizeThreshold);
loadConfig(ClassicTestConstants.JORAN_INPUT_PREFIX + "rolling/" + testId
- + ".xml");
+ + ".xml");
Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
expectedFilenameList.add(randomOutputDir + "z" + testId);
RollingFileAppender<ILoggingEvent> rfa = (RollingFileAppender<ILoggingEvent>) root
- .getAppender("ROLLING");
+ .getAppender("ROLLING");
StatusChecker sc = new StatusChecker(lc);
assertTrue(sc.isErrorFree());
TimeBasedRollingPolicy tprp = (TimeBasedRollingPolicy<ILoggingEvent>) rfa
- .getTriggeringPolicy();
+ .getTriggeringPolicy();
TimeBasedFileNamingAndTriggeringPolicy tbnatp = tprp
- .getTimeBasedFileNamingAndTriggeringPolicy();
+ .getTimeBasedFileNamingAndTriggeringPolicy();
int timeIncrement = 1000 / approxWritesPerPeriod;
int runLength = approxWritesPerPeriod * 3;
@@ -140,19 +140,19 @@ public class TimeBasedRollingWithConfigFileTest extends
// match exactly the expected archive files. Thus, we aim for
// an approximate match
assertTrue("exitenceCount=" + eCount + ", expectedFilenameList.size="
- + expectedFilenameList.size(), eCount >= 4
- && eCount > expectedFilenameList.size() / 2);
+ + expectedFilenameList.size(), eCount >= 4
+ && eCount > expectedFilenameList.size() / 2);
}
void addExpectedFileNamedIfItsTime(String testId, String msg,
- boolean gzExtension) {
+ boolean gzExtension) {
fileSize += msg.getBytes().length;
if (passThresholdTime(nextRolloverThreshold)) {
fileIndexCounter = 0;
fileSize = 0;
addExpectedFileName(testId, getDateOfPreviousPeriodsStart(),
- fileIndexCounter, gzExtension);
+ fileIndexCounter, gzExtension);
recomputeRolloverThreshold(currentTime);
return;
}
@@ -161,17 +161,17 @@ public class TimeBasedRollingWithConfigFileTest extends
// fileIndexCounter 0 and 1
if ((fileIndexCounter < 1) && fileSize > sizeThreshold) {
addExpectedFileName(testId, getDateOfPreviousPeriodsStart(),
- ++fileIndexCounter, gzExtension);
+ ++fileIndexCounter, gzExtension);
fileSize = -1;
return;
}
}
void addExpectedFileName(String testId, Date date, int fileIndexCounter,
- boolean gzExtension) {
+ boolean gzExtension) {
String fn = randomOutputDir + testId + "-" + SDF.format(date) + "."
- + fileIndexCounter;
+ + fileIndexCounter;
System.out.println("Adding " + fn);
if (gzExtension) {
fn += ".gz";
@@ -180,11 +180,11 @@ public class TimeBasedRollingWithConfigFileTest extends
}
@Override
- protected void addExpectedFileNamedIfItsTime_ByDate(String testId,
- boolean gzExtension) {
+ protected void addExpectedFileNamedIfItsTime_ByDate(String outputDir, String testId,
+ boolean gzExtension) {
if (passThresholdTime(nextRolloverThreshold)) {
- addExpectedFileName_ByDate(testId, getDateOfPreviousPeriodsStart(),
- gzExtension);
+ addExpectedFileName_ByDate(outputDir, testId, getDateOfPreviousPeriodsStart(),
+ gzExtension);
recomputeRolloverThreshold(currentTime);
}
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/AppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/AppenderBase.java
index b6939bf..9733b34 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/AppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/AppenderBase.java
@@ -122,10 +122,6 @@ abstract public class AppenderBase<E> extends ContextAwareBase implements
fai.addFilter(newFilter);
}
- public Filter getFirstFilter() {
- return fai.getFirstFilter();
- }
-
public void clearAllFilters() {
fai.clearAllFilters();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
index 1dfbb39..c26d0c6 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
@@ -152,7 +152,7 @@ public class FileAppender<E> extends OutputStreamAppender<E> {
public void openFile(String file_name) throws IOException {
synchronized (lock) {
File file = new File(file_name);
- if (FileUtil.mustCreateParentDirectories(file)) {
+ if (FileUtil.isParentDirectoryCreationRequired(file)) {
boolean result = FileUtil.createMissingParentDirectories(file);
if (!result) {
addError("Failed to create parent directories for ["
diff --git a/logback-core/src/main/java/ch/qos/logback/core/UnsynchronizedAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/UnsynchronizedAppenderBase.java
index 8c9efe3..64a0d20 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/UnsynchronizedAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/UnsynchronizedAppenderBase.java
@@ -128,10 +128,6 @@ abstract public class UnsynchronizedAppenderBase<E> extends ContextAwareBase imp
fai.addFilter(newFilter);
}
- public Filter getFirstFilter() {
- return fai.getFirstFilter();
- }
-
public void clearAllFilters() {
fai.clearAllFilters();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java
index e76b0f0..cab4c4b 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedFileNamingAndTriggeringPolicy.java
@@ -1,84 +1,84 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.core.rolling;
-
-import ch.qos.logback.core.rolling.helper.ArchiveRemover;
-import ch.qos.logback.core.spi.ContextAware;
-
-/**
- * This interface lists the set of methods that need to be implemented by
- * triggering policies which are nested within a {@link TimeBasedRollingPolicy}.
- *
- * @author Ceki Gülcü
- *
- * @param <E>
- */
-public interface TimeBasedFileNamingAndTriggeringPolicy<E> extends
- TriggeringPolicy<E>, ContextAware {
-
- /**
- * Set the host/parent {@link TimeBasedRollingPolicy}.
- *
- * @param the
- * parent TimeBasedRollingPolicy
- */
- void setTimeBasedRollingPolicy(TimeBasedRollingPolicy<E> tbrp);
-
- /**
- * Return the file name for the elapsed periods file name.
- *
- * @return
- */
- String getElapsedPeriodsFileName();
-
- /**
- * Return the current periods file name without the compression suffix. This
- * value is equivalent to the active file name.
- *
- * @return current period's file name (without compression suffix)
- */
- String getCurrentPeriodsFileNameWithoutCompressionSuffix();
-
- /**
- * Return the archive remover appropriate for this instance.
- */
- public ArchiveRemover getArchiveRemover();
-
- /**
- * Return the current time which is usually the value returned by
- * System.currentMillis(). However, for <b>testing</b> purposed this value
- * may be different than the real time.
- *
- * @return current time value
- */
- long getCurrentTime();
-
- /**
- * Set the current time. Only unit tests should invoke this method.
- *
- * @param now
- */
- void setCurrentTime(long now);
-
- /**
- * Set some date in the current period. Only unit tests should invoke this
- * method.
- *
- * WARNING: method removed. A unit test should not set the
- * date in current period. It is the job of the FNATP to compute that.
- *
- * @param date
- */
- //void setDateInCurrentPeriod(Date date);
-}
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.rolling;
+
+import ch.qos.logback.core.rolling.helper.ArchiveRemover;
+import ch.qos.logback.core.spi.ContextAware;
+
+/**
+ * This interface lists the set of methods that need to be implemented by
+ * triggering policies which are nested within a {@link TimeBasedRollingPolicy}.
+ *
+ * @author Ceki Gülcü
+ *
+ * @param <E>
+ */
+public interface TimeBasedFileNamingAndTriggeringPolicy<E> extends
+ TriggeringPolicy<E>, ContextAware {
+
+ /**
+ * Set the host/parent {@link TimeBasedRollingPolicy}.
+ *
+ * @param tbrp
+ * parent TimeBasedRollingPolicy
+ */
+ void setTimeBasedRollingPolicy(TimeBasedRollingPolicy<E> tbrp);
+
+ /**
+ * Return the file name for the elapsed periods file name.
+ *
+ * @return
+ */
+ String getElapsedPeriodsFileName();
+
+ /**
+ * Return the current periods file name without the compression suffix. This
+ * value is equivalent to the active file name.
+ *
+ * @return current period's file name (without compression suffix)
+ */
+ String getCurrentPeriodsFileNameWithoutCompressionSuffix();
+
+ /**
+ * Return the archive remover appropriate for this instance.
+ */
+ public ArchiveRemover getArchiveRemover();
+
+ /**
+ * Return the current time which is usually the value returned by
+ * System.currentMillis(). However, for <b>testing</b> purposed this value
+ * may be different than the real time.
+ *
+ * @return current time value
+ */
+ long getCurrentTime();
+
+ /**
+ * Set the current time. Only unit tests should invoke this method.
+ *
+ * @param now
+ */
+ void setCurrentTime(long now);
+
+ /**
+ * Set some date in the current period. Only unit tests should invoke this
+ * method.
+ *
+ * WARNING: method removed. A unit test should not set the
+ * date in current period. It is the job of the FNATP to compute that.
+ *
+ * @param date
+ */
+ //void setDateInCurrentPeriod(Date date);
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
index 9de332b..ec13f36 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
@@ -70,6 +70,7 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
compressor = new Compressor(compressionMode);
compressor.setContext(context);
+ // wcs : without compression suffix
fileNamePatternWCS = new FileNamePattern(computeFileNameStr_WCS(
fileNamePatternStr, compressionMode), this.context);
@@ -126,7 +127,7 @@ public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements
if (compressionMode == CompressionMode.NONE) {
if (getParentsRawFileProperty() != null) {
renameUtil.rename(getParentsRawFileProperty(), elapsedPeriodsFileName);
- }
+ } // else { nothing to do if CompressionMode == NONE and parentsRawFileProperty == null }
} else {
if (getParentsRawFileProperty() == null) {
future = asyncCompress(elapsedPeriodsFileName, elapsedPeriodsFileName);
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RenameUtil.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RenameUtil.java
index 81b9a33..c609cc0 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RenameUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RenameUtil.java
@@ -21,40 +21,44 @@ import java.io.IOException;
import ch.qos.logback.core.rolling.RolloverFailure;
import ch.qos.logback.core.spi.ContextAwareBase;
+import ch.qos.logback.core.util.FileUtil;
/**
* Utility class to help solving problems encountered while renaming files.
- * @author Ceki Gulcu
+ *
+ * @author Ceki Gulcu
*/
public class RenameUtil extends ContextAwareBase {
-
+
/**
* A robust file renaming method which in case of failure falls back to
* renaming by copying. In case, the file to be renamed is open by another
* process, renaming by copying will succeed whereas regular renaming will
* fail. However, renaming by copying is much slower.
- *
+ *
* @param from
* @param to
* @throws RolloverFailure
*/
public void rename(String from, String to) throws RolloverFailure {
- if(from.equals(to)) {
- addWarn("From and to file are the same ["+from+"]. Skipping.");
+ if (from.equals(to)) {
+ addWarn("From and to file are the same [" + from + "]. Skipping.");
return;
}
File fromFile = new File(from);
if (fromFile.exists()) {
File toFile = new File(to);
- addInfo("Renaming file ["+fromFile+"] to ["+toFile+"]");
+ createMissingTargetDirsIfNecessary(toFile);
+
+ addInfo("Renaming file [" + fromFile + "] to [" + toFile + "]");
boolean result = fromFile.renameTo(toFile);
if (!result) {
- addWarn("Failed to rename file ["+fromFile+"] to ["+toFile+"].");
+ addWarn("Failed to rename file [" + fromFile + "] to [" + toFile + "].");
addWarn("Attempting to rename by copying.");
renameByCopying(from, to);
}
@@ -63,10 +67,10 @@ public class RenameUtil extends ContextAwareBase {
}
}
- static final int BUF_SIZE = 32*1024;
-
+ static final int BUF_SIZE = 32 * 1024;
+
public void renameByCopying(String from, String to)
- throws RolloverFailure {
+ throws RolloverFailure {
try {
FileInputStream fis = new FileInputStream(from);
FileOutputStream fos = new FileOutputStream(to);
@@ -83,14 +87,24 @@ public class RenameUtil extends ContextAwareBase {
File fromFile = new File(from);
if (!fromFile.delete()) {
- addWarn("Could not delete "+ from);
+ addWarn("Could not delete " + from);
}
} catch (IOException ioe) {
addError("Failed to rename file by copying", ioe);
throw new RolloverFailure("Failed to rename file by copying");
}
}
-
+
+ void createMissingTargetDirsIfNecessary(File toFile) throws RolloverFailure {
+ if (FileUtil.isParentDirectoryCreationRequired(toFile)) {
+ boolean result = FileUtil.createMissingParentDirectories(toFile);
+ if (!result) {
+ throw new RolloverFailure("Failed to create parent directories for ["
+ + toFile.getAbsolutePath() + "]");
+ }
+ }
+ }
+
@Override
public String toString() {
return "c.q.l.co.rolling.helper.RenameUtil";
diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachable.java b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachable.java
index 72eda36..4cc4883 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachable.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachable.java
@@ -28,14 +28,6 @@ public interface FilterAttachable<E> {
*/
public void addFilter(Filter<E> newFilter);
- /**
- * Get first filter in the chain.
- *
- * @deprecated This method will be removed in future versions. Please use
- * {@link #getCopyOfAttachedFiltersList()} method instead.
- */
- public Filter getFirstFilter();
-
public void clearAllFilters();
/**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java
index 2b72bd4..3c84db6 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/spi/FilterAttachableImpl.java
@@ -36,17 +36,6 @@ final public class FilterAttachableImpl<E> implements FilterAttachable<E> {
}
/**
- * Get first filter in the chain.
- */
- public Filter<E> getFirstFilter() {
- if (filterList.size() > 0) {
- return filterList.get(0);
- } else {
- return null;
- }
- }
-
- /**
* Clear the filter chain
*/
public void clearAllFilters() {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
index 84e03af..2681140 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
@@ -25,7 +25,7 @@ import java.net.URLConnection;
public class FileUtil {
- static public boolean mustCreateParentDirectories(File file) {
+ static public boolean isParentDirectoryCreationRequired(File file) {
File parent = file.getParentFile();
if (parent != null && !parent.exists()) {
return true;
@@ -36,7 +36,7 @@ public class FileUtil {
static public boolean createMissingParentDirectories(File file) {
File parent = file.getParentFile();
- if (parent == null || parent.exists()) {
+ if (parent == null) {
throw new IllegalStateException(file + " should not have a null parent");
}
if (parent.exists()) {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java
index d3022ed..c17a6cc 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java
@@ -84,7 +84,7 @@ public class FileAppenderTest extends AbstractAppenderTest<Object> {
appender.start();
appender.doAppend(new Object());
appender.stop();
- assertFalse(FileUtil.mustCreateParentDirectories(file));
+ assertFalse(FileUtil.isParentDirectoryCreationRequired(file));
assertTrue(file.exists());
// cleanup
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/DelayerUtil.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/DelayerUtil.java
deleted file mode 100644
index 995c768..0000000
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/DelayerUtil.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.core.rolling;
-
-import java.util.Calendar;
-import java.util.Date;
-
-public class DelayerUtil {
-
- // delay until millis in the next second
- static void delayUntilNextSecond(int millis) {
- long now = System.currentTimeMillis();
- Calendar cal = Calendar.getInstance();
- cal.setTime(new Date(now));
-
- cal.set(Calendar.MILLISECOND, millis);
- cal.add(Calendar.SECOND, 1);
-
- long next = cal.getTime().getTime();
-
- try {
- Thread.sleep(next - now);
- } catch (Exception e) {
- }
- }
-
- static void delayUntilNextMinute(int seconds) {
- long now = System.currentTimeMillis();
- Calendar cal = Calendar.getInstance();
- cal.setTime(new Date(now));
-
- cal.set(Calendar.SECOND, seconds);
- cal.add(Calendar.MINUTE, 1);
-
- long next = cal.getTime().getTime();
-
- try {
- Thread.sleep(next - now);
- } catch (Exception e) {
- }
- }
-}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java
index 94e8ca5..c9d64df 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java
@@ -17,7 +17,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
-(a)Suite.SuiteClasses( { RenamingTest.class, SizeBasedRollingTest.class,
+(a)Suite.SuiteClasses( { RenameUtilTest.class, SizeBasedRollingTest.class,
TimeBasedRollingTest.class, TimeBasedRollingWithArchiveRemovalTest.class,
MultiThreadedRollingTest.class,
SizeAndTimeBasedFNATP_Test.class,
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/RenameUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/RenameUtilTest.java
new file mode 100644
index 0000000..282974c
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/RenameUtilTest.java
@@ -0,0 +1,123 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.rolling;
+
+import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.rolling.helper.RenameUtil;
+import ch.qos.logback.core.status.StatusChecker;
+import ch.qos.logback.core.testUtil.RandomUtil;
+import ch.qos.logback.core.util.StatusPrinter;
+import org.junit.Before;
+import org.junit.Test;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.encoder.EchoEncoder;
+import ch.qos.logback.core.encoder.Encoder;
+import ch.qos.logback.core.util.Compare;
+import ch.qos.logback.core.util.CoreTestConstants;
+
+public class RenameUtilTest {
+
+ Encoder<Object> encoder;
+ Context context = new ContextBase();
+ StatusChecker statusChecker = new StatusChecker(context);
+
+ long currentTime = System.currentTimeMillis();
+ int diff = RandomUtil.getPositiveInt();
+ protected String randomOutputDirAsStr = CoreTestConstants.OUTPUT_DIR_PREFIX + diff
+ + "/";
+ protected File randomOutputDir = new File(randomOutputDirAsStr);
+
+ @Before
+ public void setUp() throws Exception {
+ encoder = new EchoEncoder<Object>();
+ // if this this the fist test run after 'build clean up' then the
+ // OUTPUT_DIR_PREFIX might be not yet created
+ randomOutputDir.mkdirs();
+ }
+
+
+ /**
+ * This test case aims to unit test/reproduce problems encountered while
+ * renaming the log file under windows. However, it is not clear how
+ * the test lives up to this claim.
+ */
+ @Test
+ public void rename() throws Exception {
+ RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
+ rfa.setEncoder(encoder);
+ rfa.setContext(context);
+
+ // rollover by the second
+ String datePattern = "yyyy-MM-dd_HH_mm_ss";
+ SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
+ String[] filenames = new String[2];
+
+ TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
+ tbrp.setFileNamePattern(randomOutputDirAsStr + "test-%d{"
+ + datePattern + "}");
+ tbrp.setContext(context);
+ tbrp.setParent(rfa);
+ tbrp.start();
+
+ TimeBasedFileNamingAndTriggeringPolicy tbnatp = tbrp
+ .getTimeBasedFileNamingAndTriggeringPolicy();
+ tbnatp.setCurrentTime(currentTime);
+
+ rfa.setRollingPolicy(tbrp);
+ rfa.start();
+
+ rfa.doAppend("Hello 0");
+
+ filenames[0] = randomOutputDirAsStr + "test-" + sdf.format(currentTime);
+
+ // set currentTime to next second plus 50 millis
+ currentTime += 1000 - (currentTime % 1000) + 50;
+ tbnatp.setCurrentTime(currentTime);
+
+ rfa.doAppend("Hello 1");
+
+ filenames[1] = randomOutputDirAsStr + "test-" + sdf.format(currentTime);
+
+ for (int i = 0; i < filenames.length; i++) {
+ assertTrue(Compare.compare(filenames[i], CoreTestConstants.TEST_DIR_PREFIX
+ + "witness/rolling/renaming." + i));
+ }
+ }
+
+ @Test
+ public void renameToNonExistingDirectory() throws IOException, RolloverFailure {
+ RenameUtil renameUtil = new RenameUtil();
+ renameUtil.setContext(context);
+
+ int diff2 = RandomUtil.getPositiveInt();
+ File fromFile = File.createTempFile("from" + diff, "test",
+ randomOutputDir);
+
+ String randomTARGETDir = CoreTestConstants.OUTPUT_DIR_PREFIX+diff2;
+
+ renameUtil.rename(fromFile.toString(), new File(randomTARGETDir + "/to.test").toString());
+ StatusPrinter.printInCaseOfErrorsOrWarnings(context);
+ assertTrue(statusChecker.isErrorFree());
+ }
+
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
deleted file mode 100644
index b1e43e1..0000000
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.core.rolling;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import ch.qos.logback.core.Context;
-import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.encoder.EchoEncoder;
-import ch.qos.logback.core.encoder.Encoder;
-import ch.qos.logback.core.util.Compare;
-import ch.qos.logback.core.util.CoreTestConstants;
-
-/**
- *
- * This test case aims to unit test/reproduce problems encountered while
- * renaming the log file under windows.
- *
- * @author Ceki
- *
- */
-public class RenamingTest {
-
- Encoder<Object> encoder;
- Context context = new ContextBase();
-
- @Before
- public void setUp() throws Exception {
- encoder = new EchoEncoder<Object>();
-
- File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "test.log");
- target.mkdirs();
- target.delete();
- }
-
- @Test
- public void testRename() throws Exception {
-
- RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
- rfa.setEncoder(encoder);
- rfa.setContext(context);
-
- // rollover by the second
- String datePattern = "yyyy-MM-dd_HH_mm_ss";
- SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
- String[] filenames = new String[2];
-
- TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
- tbrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "test-%d{"
- + datePattern + "}");
- tbrp.setContext(context);
- tbrp.setParent(rfa);
- tbrp.start();
-
- rfa.setRollingPolicy(tbrp);
- rfa.start();
-
-
- Calendar cal0 = Calendar.getInstance();
- rfa.doAppend("Hello 0");
-
- DelayerUtil.delayUntilNextSecond(50);
-
- Calendar cal1 = Calendar.getInstance();
- rfa.doAppend("Hello 1");
-
- filenames[0] = CoreTestConstants.OUTPUT_DIR_PREFIX + "test-"
- + sdf.format(cal0.getTime());
- filenames[1] = CoreTestConstants.OUTPUT_DIR_PREFIX + "test-"
- + sdf.format(cal1.getTime());
-
-
- for (int i = 0; i < filenames.length; i++) {
- assertTrue(Compare.compare(filenames[i], CoreTestConstants.TEST_DIR_PREFIX
- + "witness/rolling/renaming." + i));
- }
- }
-}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java
index 633e1db..3993f82 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java
@@ -38,19 +38,18 @@ import ch.qos.logback.core.util.CoreTestConstants;
/**
* Scaffolding for various rolling tests. Some assumptions are made: - rollover
* periodicity is 1 second (without precluding size based roll-over)
- *
+ *
* @author Ceki Gülcü
- *
*/
public class ScaffoldingForRollingTests {
static public final String DATE_PATTERN_WITH_SECONDS = "yyyy-MM-dd_HH_mm_ss";
static public final SimpleDateFormat SDF = new SimpleDateFormat(
- DATE_PATTERN_WITH_SECONDS);
+ DATE_PATTERN_WITH_SECONDS);
int diff = RandomUtil.getPositiveInt();
protected String randomOutputDir = CoreTestConstants.OUTPUT_DIR_PREFIX + diff
- + "/";
+ + "/";
EchoEncoder<Object> encoder = new EchoEncoder<Object>();
Context context = new ContextBase();
protected List<String> expectedFilenameList = new ArrayList<String>();
@@ -68,7 +67,7 @@ public class ScaffoldingForRollingTests {
public static void existenceCheck(String filename) {
assertTrue("File " + filename + " does not exist", new File(filename)
- .exists());
+ .exists());
}
public static File[] getFilesInDirectory(String outputDirStr) {
@@ -77,7 +76,7 @@ public class ScaffoldingForRollingTests {
}
public static void fileContentCheck(File[] fileArray, int runLength,
- String prefix) throws IOException {
+ String prefix) throws IOException {
List<String> stringList = new ArrayList<String>();
for (File file : fileArray) {
FileToBufferUtil.readIntoList(file, stringList);
@@ -92,14 +91,14 @@ public class ScaffoldingForRollingTests {
}
public static void sortedContentCheck(String outputDirStr, int runLength,
- String prefix) throws IOException {
+ String prefix) throws IOException {
File[] fileArray = getFilesInDirectory(outputDirStr);
FileFilterUtil.sortFileArrayByName(fileArray);
fileContentCheck(fileArray, runLength, prefix);
}
public static void reverseSortedContentCheck(String outputDirStr,
- int runLength, String prefix) throws IOException {
+ int runLength, String prefix) throws IOException {
File[] fileArray = getFilesInDirectory(outputDirStr);
FileFilterUtil.reverseSortFileArrayByName(fileArray);
fileContentCheck(fileArray, runLength, prefix);
@@ -108,7 +107,7 @@ public class ScaffoldingForRollingTests {
public static void existenceCheck(List<String> filenameList) {
for (String filename : filenameList) {
assertTrue("File " + filename + " does not exist", new File(filename)
- .exists());
+ .exists());
}
}
@@ -127,6 +126,7 @@ public class ScaffoldingForRollingTests {
}
// assuming rollover every second
+
protected void recomputeRolloverThreshold(long ct) {
long delta = ct % 1000;
nextRolloverThreshold = (ct - delta) + 1000;
@@ -151,27 +151,27 @@ public class ScaffoldingForRollingTests {
}
static void waitForCompression(TimeBasedRollingPolicy<Object> tbrp)
- throws InterruptedException, ExecutionException, TimeoutException {
+ throws InterruptedException, ExecutionException, TimeoutException {
if (tbrp.future != null && !tbrp.future.isDone()) {
tbrp.future.get(200, TimeUnit.MILLISECONDS);
}
}
- protected void addExpectedFileName_ByDate(String testId, Date date,
- boolean gzExtension) {
+ protected void addExpectedFileName_ByDate(String outputDir, String testId, Date date,
+ boolean gzExtension) {
- String fn = randomOutputDir + testId + "-" + SDF.format(date);
+ String fn = outputDir + testId + "-" + SDF.format(date);
if (gzExtension) {
fn += ".gz";
}
expectedFilenameList.add(fn);
}
- protected void addExpectedFileNamedIfItsTime_ByDate(String testId,
- boolean gzExtension) {
+ protected void addExpectedFileNamedIfItsTime_ByDate(String outputDir, String testId,
+ boolean gzExtension) {
if (passThresholdTime(nextRolloverThreshold)) {
- addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(),
- gzExtension);
+ addExpectedFileName_ByDate(outputDir, testId, getDateOfCurrentPeriodsStart(),
+ gzExtension);
recomputeRolloverThreshold(currentTime);
}
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
index f76cac4..f918e73 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
@@ -17,6 +17,8 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
+import ch.qos.logback.core.testUtil.RandomUtil;
+import ch.qos.logback.core.util.StatusPrinter;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -28,21 +30,21 @@ import ch.qos.logback.core.util.CoreTestConstants;
* A rather exhaustive set of tests. Tests include leaving the file option
* blank, or setting it, with and without compression, and tests with or without
* stopping/restarting the RollingFileAppender.
- *
+ * <p/>
* The regression tests log a few times using a RollingFileAppender. Then, they
* predict the names of the files which should be generated and compare them
* with witness files.
- *
+ * <p/>
* <pre>
- * Compression file option Stop/Restart
+ * Compression file option Stop/Restart
* Test1 NO BLANK NO
* Test2 YES BLANK NO
* Test3 NO BLANK YES
- * Test4 NO SET YES
+ * Test4 NO SET YES
* Test5 NO SET NO
* Test6 YES SET NO
* </pre>
- *
+ *
* @author Ceki Gülcü
*/
public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
@@ -72,8 +74,8 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
}
void initTRBP(RollingFileAppender<Object> rfa,
- TimeBasedRollingPolicy<Object> tbrp, String filenamePattern,
- long givenTime) {
+ TimeBasedRollingPolicy<Object> tbrp, String filenamePattern,
+ long givenTime) {
tbrp.setContext(context);
tbrp.setFileNamePattern(filenamePattern);
tbrp.setParent(rfa);
@@ -92,17 +94,17 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
String testId = "test1";
initRFA(rfa1, null);
initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
+ + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
// compute the current filename
- addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
+ addExpectedFileName_ByDate(randomOutputDir, testId, getDateOfCurrentPeriodsStart(), false);
incCurrentTime(1100);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
for (int i = 0; i < 3; i++) {
rfa1.doAppend("Hello---" + i);
- addExpectedFileNamedIfItsTime_ByDate(testId, false);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
incCurrentTime(500);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
}
@@ -110,7 +112,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
int i = 0;
for (String fn : expectedFilenameList) {
assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
- + "witness/rolling/tbr-" + testId + "." + i++));
+ + "witness/rolling/tbr-" + testId + "." + i++));
}
}
@@ -122,15 +124,15 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
String testId = "test2";
initRFA(rfa1, null);
initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}.gz", currentTime);
+ + DATE_PATTERN_WITH_SECONDS + "}.gz", currentTime);
- addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), true);
+ addExpectedFileName_ByDate(randomOutputDir, testId, getDateOfCurrentPeriodsStart(), true);
incCurrentTime(1100);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
for (int i = 0; i < 3; i++) {
// when i == 2, file name should not have .gz extension
- addExpectedFileNamedIfItsTime_ByDate(testId, i != 2);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, i != 2);
rfa1.doAppend("Hello---" + i);
incCurrentTime(500);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
@@ -140,7 +142,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
int i = 0;
for (String fn : expectedFilenameList) {
assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
- + "witness/rolling/tbr-" + testId + "." + i + addGZIfNotLast(i)));
+ + "witness/rolling/tbr-" + testId + "." + i + addGZIfNotLast(i)));
i++;
}
}
@@ -154,17 +156,17 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
initRFA(rfa1, null);
initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
+ + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
// a new file is created by virtue of rfa.start();
- addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
+ addExpectedFileName_ByDate(randomOutputDir, testId, getDateOfCurrentPeriodsStart(), false);
incCurrentTime(1100);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
for (int i = 0; i <= 2; i++) {
rfa1.doAppend("Hello---" + i);
- addExpectedFileNamedIfItsTime_ByDate(testId, false);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
incCurrentTime(500);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
}
@@ -173,11 +175,11 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
initRFA(rfa2, null);
initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}", tbrp1.timeBasedTriggering
- .getCurrentTime());
+ + DATE_PATTERN_WITH_SECONDS + "}", tbrp1.timeBasedTriggering
+ .getCurrentTime());
for (int i = 0; i <= 2; i++) {
- addExpectedFileNamedIfItsTime_ByDate(testId, false);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
rfa2.doAppend("World---" + i);
incCurrentTime(100);
tbrp2.timeBasedTriggering.setCurrentTime(currentTime);
@@ -186,7 +188,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
int i = 0;
for (String fn : expectedFilenameList) {
assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
- + "witness/rolling/tbr-" + testId + "." + i++));
+ + "witness/rolling/tbr-" + testId + "." + i++));
}
}
@@ -198,16 +200,16 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
String testId = "test4";
initRFA(rfa1, testId2FileName(testId));
initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
+ + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
- addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
+ addExpectedFileName_ByDate(randomOutputDir, testId, getDateOfCurrentPeriodsStart(), false);
incCurrentTime(1100);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
for (int i = 0; i <= 2; i++) {
rfa1.doAppend("Hello---" + i);
- addExpectedFileNamedIfItsTime_ByDate(testId, false);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
incCurrentTime(500);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
}
@@ -220,11 +222,11 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
initRFA(rfa2, testId2FileName(testId));
initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
+ + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
for (int i = 0; i <= 2; i++) {
rfa2.doAppend("World---" + i);
- addExpectedFileNamedIfItsTime_ByDate(testId, false);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
incCurrentTime(100);
tbrp2.timeBasedTriggering.setCurrentTime(currentTime);
}
@@ -234,26 +236,26 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
int i = 0;
for (String fn : expectedFilenameList) {
assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
- + "witness/rolling/tbr-" + testId + "." + i++));
+ + "witness/rolling/tbr-" + testId + "." + i++));
}
}
@Test
public void noCompression_FileSet_StopRestart_WithLongWait_4B()
- throws Exception {
+ throws Exception {
String testId = "test4B";
initRFA(rfa1, testId2FileName(testId));
initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
+ + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
- addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
+ addExpectedFileName_ByDate(randomOutputDir, testId, getDateOfCurrentPeriodsStart(), false);
incCurrentTime(1100);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
for (int i = 0; i <= 2; i++) {
rfa1.doAppend("Hello---" + i);
- addExpectedFileNamedIfItsTime_ByDate(testId, false);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
incCurrentTime(500);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
}
@@ -268,11 +270,11 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
initRFA(rfa2, randomOutputDir + "test4B.log");
initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
+ + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
for (int i = 0; i <= 2; i++) {
rfa2.doAppend("World---" + i);
- addExpectedFileNamedIfItsTime_ByDate(testId, false);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
incCurrentTime(100);
tbrp2.timeBasedTriggering.setCurrentTime(currentTime);
}
@@ -282,7 +284,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
int i = 0;
for (String fn : expectedFilenameList) {
assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
- + "witness/rolling/tbr-test4B." + i++));
+ + "witness/rolling/tbr-test4B." + i++));
}
}
@@ -296,16 +298,16 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
initRFA(rfa1, testId2FileName(testId));
initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
+ + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
- addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
+ addExpectedFileName_ByDate(randomOutputDir, testId, getDateOfCurrentPeriodsStart(), false);
incCurrentTime(1100);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
for (int i = 0; i < 3; i++) {
rfa1.doAppend("Hello---" + i);
- addExpectedFileNamedIfItsTime_ByDate(testId, false);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
incCurrentTime(500);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
}
@@ -315,7 +317,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
int i = 0;
for (String fn : expectedFilenameList) {
assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
- + "witness/rolling/tbr-test5." + i++));
+ + "witness/rolling/tbr-test5." + i++));
}
}
@@ -329,16 +331,16 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
initRFA(rfa1, testId2FileName(testId));
initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}.gz", currentTime);
+ + DATE_PATTERN_WITH_SECONDS + "}.gz", currentTime);
- addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), true);
+ addExpectedFileName_ByDate(randomOutputDir, testId, getDateOfCurrentPeriodsStart(), true);
incCurrentTime(1100);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
for (int i = 0; i < 3; i++) {
rfa1.doAppend("Hello---" + i);
- addExpectedFileNamedIfItsTime_ByDate(testId, true);
+ addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, true);
incCurrentTime(500);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
waitForCompression(tbrp1);
@@ -349,11 +351,46 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
int i = 0;
for (String fn : expectedFilenameList) {
assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
- + "witness/rolling/tbr-" + testId + "." + i + addGZIfNotLast(i)));
+ + "witness/rolling/tbr-" + testId + "." + i + addGZIfNotLast(i)));
i++;
}
}
+ @Test
+ public void withMissingTargetDir() throws Exception {
+ String testId = "missingTargetDir";
+
+ initRFA(rfa1, testId2FileName(testId));
+ int secondDiff = RandomUtil.getPositiveInt();
+ String randomTargetDir = CoreTestConstants.OUTPUT_DIR_PREFIX + secondDiff + '/';
+
+ System.out.println("randomOutputDir"+randomOutputDir);
+ System.out.println("randomTargetDir"+randomTargetDir);
+
+ initTRBP(rfa1, tbrp1, randomTargetDir + testId + "-%d{"
+ + DATE_PATTERN_WITH_SECONDS + "}", currentTime);
+
+ addExpectedFileName_ByDate(randomTargetDir, testId, getDateOfCurrentPeriodsStart(), false);
+
+ incCurrentTime(1100);
+ tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
+
+ for (int i = 0; i < 3; i++) {
+ rfa1.doAppend("Hello---" + i);
+ addExpectedFileNamedIfItsTime_ByDate(randomTargetDir, testId, false);
+ incCurrentTime(500);
+ tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
+ }
+ massageExpectedFilesToCorresponToCurrentTarget("missingTargetDir.log");
+ int i = 0;
+ for (String fn : expectedFilenameList) {
+ System.out.println("expectedFile="+fn);
+ assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+ + "witness/rolling/tbr-test5." + i++));
+ }
+
+ }
+
// =========================================================================
// utility methods
// =========================================================================
diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java
index b392c91..23b072f 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java
@@ -51,9 +51,9 @@ public class FileUtilTest {
cleanupList.add(file);
cleanupList.add(file.getParentFile());
- assertTrue(FileUtil.mustCreateParentDirectories(file));
+ assertTrue(FileUtil.isParentDirectoryCreationRequired(file));
assertTrue(FileUtil.createMissingParentDirectories(file));
- assertFalse(FileUtil.mustCreateParentDirectories(file));
+ assertFalse(FileUtil.isParentDirectoryCreationRequired(file));
}
@Test
@@ -65,8 +65,8 @@ public class FileUtilTest {
cleanupList.add(file.getParentFile());
cleanupList.add(file.getParentFile().getParentFile());
- assertTrue(FileUtil.mustCreateParentDirectories(file));
+ assertTrue(FileUtil.isParentDirectoryCreationRequired(file));
assertTrue(FileUtil.createMissingParentDirectories(file));
- assertFalse(FileUtil.mustCreateParentDirectories(file));
+ assertFalse(FileUtil.isParentDirectoryCreationRequired(file));
}
}
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 398366a..7689704 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -30,7 +30,7 @@
<h3>April xx, 2010 - Release of version 0.9.21</h3>
- <p>SLF4J dependency upgraded to 1.6.0-RC0.</p>
+ <p>SLF4J dependency upgraded to 1.6.0</p>
<p>Fixed concurrency problem in <code>SiftingAppender</code> as
reported in <a
@@ -43,6 +43,12 @@
which processes boolean expression written in the Groovy language.
</p>
+ <p>Fixed rollover problem occuring when the target directory was
+ missing as reported in <a
+ href="http://jira.qos.ch/browse/LBCORE-151">LBCORE-151</a> by
+ Torsten Juergeleit.
+ </p>
+
<hr width="80%" align="center" />
@@ -71,6 +77,8 @@
href="http://jira.qos.ch/browse/LBCLASSIC-87">LBCLASSIC-87</a>.
</p>
+ <p>Removed the previously deprecated <code>getFirstFilter</code>
+ method in <code>FilterAttachable</code> interface.</p>
<!-- ============================================================== -->
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=cbd336b71ef1842babf7ccdc…
http://github.com/ceki/logback/commit/cbd336b71ef1842babf7ccdcf59e63861beef…
commit cbd336b71ef1842babf7ccdcf59e63861beef0ab
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Sat May 8 14:58:09 2010 +0200
- upgrade to SLF4J 1.6.0
- minor corrections
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextDeadlockTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextDeadlockTest.java
index 954cf03..8c7a4ed 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextDeadlockTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextDeadlockTest.java
@@ -37,14 +37,14 @@ public class LoggerContextDeadlockTest {
public void tearDown() throws Exception {
}
- @Test(timeout=20000)
+ @Test(timeout = 20000)
public void testLBCLASSIC_81() throws JoranException {
getLoggerThread.start();
for (int i = 0; i < 500; i++) {
- ByteArrayInputStream baos = new ByteArrayInputStream(new String(
- "<configuration><root level=\"DEBUG\"/></configuration>").getBytes());
+ ByteArrayInputStream baos = new ByteArrayInputStream(
+ "<configuration><root level=\"DEBUG\"/></configuration>".getBytes());
jc.doConfigure(baos);
}
}
@@ -52,13 +52,15 @@ public class LoggerContextDeadlockTest {
class GetLoggerThread extends Thread {
final LoggerContext loggerContext;
+
GetLoggerThread(LoggerContext loggerContext) {
this.loggerContext = loggerContext;
}
+
@Override
public void run() {
for (int i = 0; i < 10000; i++) {
- if(i % 100 == 0) {
+ if (i % 100 == 0) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
index 8c9cd2e..d3706ac 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
@@ -158,7 +158,7 @@ public class HTMLLayoutTest {
{
Element tdElement = (Element) trElement.elements().get(1);
String regex = ClassicTestConstants.NAKED_MAIN_REGEX;
- assertTrue(tdElement.getText().toString().matches(regex));
+ assertTrue(tdElement.getText().matches(regex));
}
{
Element tdElement = (Element) trElement.elements().get(2);
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java
index 824a349..667d409 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java
@@ -43,7 +43,7 @@ public class CompositeConverter<E> extends FormattingConverter<E> {
buf.append(formattingInfo);
if (childConverter != null) {
- buf.append(", children: "+childConverter);
+ buf.append(", children: ").append(childConverter);
}
buf.append(">");
return buf.toString();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java b/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java
index 05b5d18..d897591 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java
@@ -43,7 +43,7 @@ public class ThrowableToStringArrayTest {
String[] sa = ThrowableToStringArray.convert(t);
StringBuilder sb = new StringBuilder();
for (String tdp : sa) {
- sb.append(tdp.toString());
+ sb.append(tdp);
sb.append(CoreConstants.LINE_SEPARATOR);
}
String expected = sw.toString();
diff --git a/pom.xml b/pom.xml
index 88076fc..788d523 100755
--- a/pom.xml
+++ b/pom.xml
@@ -43,7 +43,7 @@
<properties>
<!-- slf4j.version property is used below, in
logback-classic/pom.xml and in setClasspath.cmd -->
- <slf4j.version>1.6.0-alpha2</slf4j.version>
+ <slf4j.version>1.6.0</slf4j.version>
<consolePlugin.version>1.1.0</consolePlugin.version>
</properties>
-----------------------------------------------------------------------
Summary of changes:
.../qos/logback/access/jetty/RequestLogImpl.java | 3 -
.../logback/access/jetty/v7/RequestLogImpl.java | 4 -
.../ch/qos/logback/access/spi/AccessContext.java | 4 -
.../ch/qos/logback/access/tomcat/LogbackValve.java | 4 -
.../logback/classic/LoggerContextDeadlockTest.java | 10 +-
.../qos/logback/classic/html/HTMLLayoutTest.java | 2 +-
.../TimeBasedRollingWithConfigFileTest.java | 42 +++---
.../java/ch/qos/logback/core/AppenderBase.java | 4 -
.../java/ch/qos/logback/core/FileAppender.java | 2 +-
.../logback/core/UnsynchronizedAppenderBase.java | 4 -
.../logback/core/pattern/CompositeConverter.java | 2 +-
.../TimeBasedFileNamingAndTriggeringPolicy.java | 168 ++++++++++----------
.../core/rolling/TimeBasedRollingPolicy.java | 3 +-
.../logback/core/rolling/helper/RenameUtil.java | 38 +++--
.../ch/qos/logback/core/spi/FilterAttachable.java | 8 -
.../qos/logback/core/spi/FilterAttachableImpl.java | 11 --
.../java/ch/qos/logback/core/util/FileUtil.java | 4 +-
.../logback/core/appender/FileAppenderTest.java | 2 +-
.../core/helpers/ThrowableToStringArrayTest.java | 2 +-
.../ch/qos/logback/core/rolling/DelayerUtil.java | 53 ------
.../ch/qos/logback/core/rolling/PackageTest.java | 2 +-
.../qos/logback/core/rolling/RenameUtilTest.java | 123 ++++++++++++++
.../ch/qos/logback/core/rolling/RenamingTest.java | 96 -----------
.../core/rolling/ScaffoldingForRollingTests.java | 34 ++--
.../logback/core/rolling/TimeBasedRollingTest.java | 123 +++++++++-----
.../ch/qos/logback/core/util/FileUtilTest.java | 8 +-
logback-site/src/site/pages/news.html | 10 +-
pom.xml | 2 +-
28 files changed, 381 insertions(+), 387 deletions(-)
delete mode 100644 logback-core/src/test/java/ch/qos/logback/core/rolling/DelayerUtil.java
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/rolling/RenameUtilTest.java
delete mode 100644 logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[JIRA] Created: (LBCLASSIC-208) ReconfigureOnChangeFilter.detachReconfigurationToNewThread ThreadDeath
by Mike Hanafey (JIRA) 07 May '10
by Mike Hanafey (JIRA) 07 May '10
07 May '10
ReconfigureOnChangeFilter.detachReconfigurationToNewThread ThreadDeath
----------------------------------------------------------------------
Key: LBCLASSIC-208
URL: http://jira.qos.ch/browse/LBCLASSIC-208
Project: logback-classic
Issue Type: Bug
Affects Versions: 0.9.19
Environment: Fedora 11, JDK 1.6.0_17, Glassfish v2
Reporter: Mike Hanafey
Assignee: Logback dev list
Sometimes when a web app is redeployed, the following exception is thrown with the early (first?) logging activity of the web app:
javax.el.ELException: /iplm/sideMenu.xhtml @54,94 rendered="#{MainToolBar.iplmMenu.newDocketSubscribed}": java.lang.ThreadDeath
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:390)
...
Caused by: java.lang.ThreadDeath
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1333)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter.detachReconfigurationToNewThread(ReconfigureOnChangeFilter.java:130)
at ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter.decide(ReconfigureOnChangeFilter.java:111)
at ch.qos.logback.classic.spi.TurboFilterList.getTurboFilterChainDecision(TurboFilterList.java:51)
at ch.qos.logback.classic.LoggerContext.getTurboFilterChainDecision_0_3OrMore(LoggerContext.java:259)
at ch.qos.logback.classic.Logger.callTurboFilters(Logger.java:795)
at ch.qos.logback.classic.Logger.isTraceEnabled(Logger.java:667)
at ch.qos.logback.classic.Logger.isTraceEnabled(Logger.java:663)
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.isTraceEnabled(SLF4JLocationAwareLog.java:60)
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:205)
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
at org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:922)
at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:978)
at org.springframework.jdbc.object.StoredProcedure.execute(StoredProcedure.java:144)
at genomix.trak.dao.impl.EventRegistryDaoJdbc$TrakEventRegistryCrud.isRegistered(EventRegistryDaoJdbc.java:199)
at genomix.trak.dao.impl.EventRegistryDaoJdbc.isRegistered(EventRegistryDaoJdbc.java:62)
at genomix.tractor.backing.iplm.IplmSideMenu.getNewDocketSubscribed(IplmSideMenu.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:261)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
at com.sun.el.parser.AstValue.getValue(AstValue.java:138)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
... 65 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.20-12-g5e93537
by git-noreply@pixie.qos.ch 06 May '10
by git-noreply@pixie.qos.ch 06 May '10
06 May '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via 5e93537ed06b334bd3f57f577f0545d598caae13 (commit)
from ad6b18f0229d4d221e284d0176484a52f9f00f49 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=5e93537ed06b334bd3f57f57…
http://github.com/ceki/logback/commit/5e93537ed06b334bd3f57f577f0545d598caa…
commit 5e93537ed06b334bd3f57f577f0545d598caae13
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Mon May 3 21:58:01 2010 +0200
- upgrade to SLF4J 1.6.0-alpha2
- added GEventEvaluator
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 032c8c9..045663f 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -115,6 +115,14 @@
</dependency>
<dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+
+
+ <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<type>test-jar</type>
@@ -178,8 +186,18 @@
</dependencies>
<build>
- <plugins>
+ <resources>
+ <resource>
+ <directory>src/main/groovy</directory>
+ <includes>
+ <include>**/EvaluatorTemplate.groovy</include>
+ </includes>
+ </resource>
+ </resources>
+
+
+ <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -190,6 +208,21 @@
</plugin>
<plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generateStubs</goal>
+ <goal>compile</goal>
+ <goal>generateTestStubs</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
@@ -289,15 +322,14 @@ org.slf4j.test_osgi
config files). They won't be found by Bnd's analysis
of java code. -->
- <!-- importing ch.qos.logback.classic.util is strange but
- is required for the OSGi integration tests to pass
- -->
<Import-Package>
sun.reflect;resolution:=optional,
javax.*;resolution:=optional,
org.xml.*;resolution:=optional,
ch.qos.logback.core.rolling,
- ch.qos.logback.core.rolling.helper,
+ ch.qos.logback.core.rolling.helper,
+ org.codehaus.groovy.*;resolution:=optional,
+ groovy.lang.*;resolution:=optional,
*
</Import-Package>
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/boolex/EvaluatorTemplate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/boolex/EvaluatorTemplate.groovy
new file mode 100644
index 0000000..a090124
--- /dev/null
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/boolex/EvaluatorTemplate.groovy
@@ -0,0 +1,40 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.classic.boolex
+
+import ch.qos.logback.classic.spi.ILoggingEvent
+
+import static ch.qos.logback.classic.Level.TRACE;
+import static ch.qos.logback.classic.Level.DEBUG;
+import static ch.qos.logback.classic.Level.INFO;
+import static ch.qos.logback.classic.Level.WARN;
+import static ch.qos.logback.classic.Level.ERROR;
+
+// WARNING
+// If this file is renamed, this should be reflected in
+// logback-classic/pom.xml resources section.
+
+/**
+ * @author Ceki Gücü
+ */
+public class EvaluatorTemplate implements IEvaluator {
+
+
+ boolean doEvaluate(ILoggingEvent event) {
+ ILoggingEvent e = event;
+ //EXPRESSION
+ }
+
+
+}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/GEventEvaluator.java b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/GEventEvaluator.java
new file mode 100644
index 0000000..72a7bad
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/GEventEvaluator.java
@@ -0,0 +1,86 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+
+package ch.qos.logback.classic.boolex;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.boolex.EvaluationException;
+import ch.qos.logback.core.boolex.EventEvaluator;
+import ch.qos.logback.core.boolex.EventEvaluatorBase;
+import ch.qos.logback.core.util.FileUtil;
+import groovy.lang.*;
+import org.codehaus.groovy.control.CompilationFailedException;
+
+/**
+ * @author Ceki Gülcü
+ */
+public class GEventEvaluator extends EventEvaluatorBase<ILoggingEvent> {
+
+ String expression;
+
+ IEvaluator delegateEvaluator;
+ Script script;
+
+ public String getExpression() {
+ return expression;
+ }
+
+ public void setExpression(String expression) {
+ this.expression = expression;
+ }
+
+ public void start() {
+ if (expression == null || expression.length() == 0) {
+ addError("Empty expression");
+ return;
+ } else {
+ addInfo("Expression to evaluate [" + expression + "]");
+ }
+
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ String currentPackageName = this.getClass().getPackage().getName();
+ currentPackageName = currentPackageName.replace('.', '/');
+
+ String scriptText = FileUtil.resourceAsString(this, classLoader, currentPackageName + "/EvaluatorTemplate.groovy");
+ if(scriptText == null) {
+ return;
+ }
+
+ // insert the expression into script text
+ scriptText = scriptText.replace("//EXPRESSION", expression);
+
+ GroovyClassLoader gLoader = new GroovyClassLoader(classLoader);
+ try {
+ Class scriptClass = gLoader.parseClass(scriptText);
+
+ GroovyObject goo = (GroovyObject) scriptClass.newInstance();
+ delegateEvaluator = (IEvaluator) goo;
+
+ } catch (CompilationFailedException cfe) {
+ addError("Failed to compile expression [" + expression + "]", cfe);
+ } catch (Exception e) {
+ addError("Failed to compile expression [" + expression + "]", e);
+ }
+ }
+
+ public boolean evaluate(ILoggingEvent event) throws NullPointerException, EvaluationException {
+ if(delegateEvaluator == null) {
+ return false;
+ }
+ return delegateEvaluator.doEvaluate(event);
+ }
+
+
+}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/boolex/IEvaluator.java b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/IEvaluator.java
new file mode 100644
index 0000000..db79bf8
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/boolex/IEvaluator.java
@@ -0,0 +1,26 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.classic.boolex;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+
+/**
+ * An <b>internal</b> interface used by the GEventEvaluator.
+ *
+ * @author Ceki Gücü
+ */
+public interface IEvaluator {
+ public boolean doEvaluate(ILoggingEvent event);
+}
+
\ No newline at end of file
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java
index b6edbdb..a550040 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java
@@ -69,8 +69,15 @@ public interface ILoggingEvent extends DeferredProcessingAware {
public Marker getMarker();
+ /**
+ * Returns the MDC map.
+ */
public Map<String, String> getMDCPropertyMap();
+ /**
+ * Synonym for [@link #getMDCPropertyMap}.
+ */
+ public Map<String, String> getMdc();
public long getTimeStamp();
public void prepareForDeferredProcessing();
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
index 774c5fd..8cbf883 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
@@ -312,6 +312,10 @@ public class LoggingEvent implements ILoggingEvent {
return mdcPropertyMap;
}
+ public Map<String, String> getMdc() {
+ return mdcPropertyMap;
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java
index c55b281..d8228d2 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEventVO.java
@@ -149,7 +149,10 @@ public class LoggingEventVO implements ILoggingEvent, Serializable {
public Map<String, String> getMDCPropertyMap() {
return mdcPropertyMap;
}
-
+ public Map<String, String> getMdc() {
+ return mdcPropertyMap;
+ }
+
public void prepareForDeferredProcessing() {
}
diff --git a/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
index 9e6ee66..fe80bb7 100644
--- a/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
+++ b/logback-classic/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
@@ -40,7 +40,7 @@ public class StaticLoggerBinder implements LoggerFactoryBinder {
* against. The value of this field is usually modified with each release.
*/
// to avoid constant folding by the compiler, this field must *not* be final
- public static String REQUESTED_API_VERSION = "1.5.11"; // !final
+ public static String REQUESTED_API_VERSION = "1.6"; // !final
final static String NULL_CS_URL = CoreConstants.CODES_URL + "#null_CS";
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/GEventEvaluatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/GEventEvaluatorTest.java
new file mode 100644
index 0000000..5fe551f
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/GEventEvaluatorTest.java
@@ -0,0 +1,147 @@
+package ch.qos.logback.classic.boolex;
+
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.boolex.EvaluationException;
+import ch.qos.logback.core.status.StatusChecker;
+import ch.qos.logback.core.util.StatusPrinter;
+import org.junit.Test;
+import org.slf4j.MDC;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+import org.slf4j.helpers.BogoPerf;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Ceki Gücü
+ */
+
+public class GEventEvaluatorTest {
+
+ LoggerContext context = new LoggerContext();
+ StatusChecker statusChecker = new StatusChecker(context);
+ int LEN = 100 * 1000;
+
+ Logger logger = context.getLogger(this.getClass());
+ Marker markerA = MarkerFactory.getMarker("A");
+
+ LoggingEvent makeEvent(String msg) {
+ return makeEvent(Level.DEBUG, msg, null, null);
+ }
+
+ LoggingEvent makeEvent(Level level, String msg, Throwable t, Object[] argArray) {
+ return new LoggingEvent(this.getClass().getName(), logger, level, msg, t, argArray);
+ }
+
+ void doEvaluateAndCheck(String expression, ILoggingEvent event, boolean expected) throws EvaluationException {
+ GEventEvaluator gee = new GEventEvaluator();
+ gee.setContext(context);
+ gee.setExpression(expression);
+ gee.start();
+
+ StatusPrinter.printInCaseOfErrorsOrWarnings(context);
+ assertTrue(statusChecker.isErrorFree());
+
+
+ boolean result = gee.evaluate(event);
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void smoke() throws EvaluationException {
+ doEvaluateAndCheck("1==1", null, true);
+ }
+
+ @Test
+ public void event() throws EvaluationException {
+ ILoggingEvent event = makeEvent("x");
+ event.getLoggerContextVO();
+ doEvaluateAndCheck("e.message == 'x'", event, true);
+ }
+
+ @Test
+ public void msgRegex() throws EvaluationException {
+ LoggingEvent event = makeEvent("Hello world");
+ // partial match
+ doEvaluateAndCheck("e.message =~ /xyz|wor/", event, true);
+ // full match
+ doEvaluateAndCheck("e.message ==~ /xyz|wor/", event, false);
+ }
+
+ @Test
+ public void level() throws EvaluationException {
+ LoggingEvent event = makeEvent("x");
+ doEvaluateAndCheck("e.level == DEBUG", event, true);
+ }
+
+
+ @Test
+ public void nullMarker() throws EvaluationException {
+ LoggingEvent event = makeEvent("x");
+ doEvaluateAndCheck("e.marker?.name == 'YELLOW'", event, false);
+ }
+
+ @Test
+ public void marker() throws EvaluationException {
+ LoggingEvent event = makeEvent("x");
+ event.setMarker(markerA);
+ doEvaluateAndCheck("e.marker?.name == 'A'", event, true);
+ }
+
+ @Test
+ public void nullMDC() throws EvaluationException {
+ LoggingEvent event = makeEvent("x");
+ doEvaluateAndCheck("e.mdc?.get('key') == 'val'", event, false);
+ }
+
+ @Test
+ public void mdc() throws EvaluationException {
+ MDC.put("key", "val");
+ LoggingEvent event = makeEvent("x");
+ doEvaluateAndCheck("e.mdc['key'] == 'val'", event, true);
+ MDC.clear();
+ }
+
+
+ @Test
+ public void callerData() throws EvaluationException {
+ LoggingEvent event = makeEvent("x");
+ doEvaluateAndCheck("e.callerData.find{ it.className =~ /junit/ }", event, true);
+ }
+
+
+ double loop(GEventEvaluator gee) throws EvaluationException {
+ long start = System.nanoTime();
+ ILoggingEvent event = makeEvent("x");
+ for (int i = 0; i < LEN; i++) {
+ gee.evaluate(event);
+ }
+ long end = System.nanoTime();
+ return (end - start) / LEN;
+ }
+
+ @Test
+ public void perfTest() throws EvaluationException {
+ GEventEvaluator gee = new GEventEvaluator();
+ gee.setContext(context);
+ gee.setExpression("event.timeStamp < 100 && event.message != 'xx' ");
+ gee.start();
+
+ loop(gee);
+ loop(gee);
+ double avgDuration = loop(gee);
+
+ long referencePerf = 500;
+ BogoPerf.assertDuration(avgDuration, referencePerf,
+ CoreConstants.REFERENCE_BIPS);
+ System.out.println("Average duration " + avgDuration);
+ }
+
+}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java
index 68d17e3..57d293b 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/PubLoggingEventVO.java
@@ -124,6 +124,10 @@ public class PubLoggingEventVO implements ILoggingEvent, Serializable {
return mdcPropertyMap;
}
+ public Map<String, String> getMdc() {
+ return mdcPropertyMap;
+ }
+
public void prepareForDeferredProcessing() {
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluatorBase.java b/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluatorBase.java
index d85dcda..58fa250 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluatorBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/boolex/EventEvaluatorBase.java
@@ -22,7 +22,6 @@ abstract public class EventEvaluatorBase<E> extends ContextAwareBase implements
boolean started;
public String getName() {
-
return name;
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
index 4b99245..2b036b0 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
@@ -159,9 +159,9 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
sendBuffer(eventObject);
}
} catch (EvaluationException ex) {
- errorCount ++;
+ errorCount ++;
if (errorCount < CoreConstants.MAX_ERROR_COUNT) {
- addError("SMTPAppender's EventEvaluator threw an Exception" + ex);
+ addError("SMTPAppender's EventEvaluator threw an Exception-", ex);
}
}
}
@@ -425,7 +425,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
*/
public String getCharsetEncoding() {
return charsetEncoding;
- }
+ }
/**
* Set the character set encoding of the outgoing email messages. The default
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
index 80fe0c7..84e03af 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
@@ -13,28 +13,64 @@
*/
package ch.qos.logback.core.util;
+import ch.qos.logback.core.spi.ContextAware;
+
import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
public class FileUtil {
- public static boolean mustCreateParentDirectories(File file) {
+ static public boolean mustCreateParentDirectories(File file) {
File parent = file.getParentFile();
- if(parent != null && !parent.exists()) {
+ if (parent != null && !parent.exists()) {
return true;
} else {
return false;
}
}
-
- public static boolean createMissingParentDirectories(File file) {
+
+ static public boolean createMissingParentDirectories(File file) {
File parent = file.getParentFile();
- if(parent == null || parent.exists()) {
+ if (parent == null || parent.exists()) {
throw new IllegalStateException(file + " should not have a null parent");
- }
- if(parent.exists()) {
+ }
+ if (parent.exists()) {
throw new IllegalStateException(file + " should not have existing parent directory");
- }
+ }
return parent.mkdirs();
}
+
+
+ static public String resourceAsString(ContextAware ca, ClassLoader classLoader, String resourceName) {
+ URL url = classLoader.getResource(resourceName);
+ if (url == null) {
+ ca.addError("Failed to find resource [" + resourceName + "]");
+ return null;
+ }
+
+ URLConnection urlConnection = null;
+ try {
+ urlConnection = url.openConnection();
+ urlConnection.setUseCaches(false);
+ InputStream is = urlConnection.getInputStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ char[] buf = new char[128];
+ StringBuilder builder = new StringBuilder();
+ int count = -1;
+ while ((count = isr.read(buf, 0, buf.length)) != -1) {
+ builder.append(buf, 0, count);
+ }
+ isr.close();
+ is.close();
+ return builder.toString();
+ } catch (IOException e) {
+ ca.addError("Failled to open " + resourceName, e);
+ }
+ return null;
+ }
}
diff --git a/logback-site/src/site/pages/manual/filters.html b/logback-site/src/site/pages/manual/filters.html
index d3b4b75..43d5e82 100644
--- a/logback-site/src/site/pages/manual/filters.html
+++ b/logback-site/src/site/pages/manual/filters.html
@@ -234,8 +234,8 @@ public class SampleFilter extends Filter>ILoggingEvent> {
</configuration></pre>
- <h3><a name="evalutatorFilter"
- href="#evalutatorFilter">EvaluatorFilter</a></h3>
+ <h2><a name="evalutatorFilter"
+ href="#evalutatorFilter">EvaluatorFilter</a></h2>
<p><a
href="../xref/ch/qos/logback/core/filter/EvaluatorFilter.html"><code>EvaluatorFilter</code></a>
@@ -250,18 +250,119 @@ public class SampleFilter extends Filter>ILoggingEvent> {
<p>The <code>EventEvaluator</code> is an abstract class and you
can implement your own event evaluation logic by sub-classing
- <code>EventEvaluator</code>. However, logback-classic also ships
- with a concrete evaluator implementation called <a
+ <code>EventEvaluator</code>.
+ </p>
+
+
+ <!-- ======================== GEventEvaluator ========================= -->
+
+ <h3><a name="GEventEvaluator"
+ href="#GEventEvaluator">GEventEvaluator</a></h3>
+
+ <p><a
+ href="../xref/ch/qos/logback/classic/boolex/GEventEvaluator.html">GEventEvaluator</a>
+ is a concrete <a
+ href="../xref/ch/qos/logback/core/boolex/EventEvaluator.html"><code>EventEvaluator</code></a>
+ implementation taking artibtrary Groovy language boolean
+ expressions as the evaluation criteria. It admits an arbitrary
+ boolean expression written in Groovy. We refer such groovy
+ language boolean expressions as "groovy evaulation
+ expressions". Groovy evaluation expressions enable hereto
+ unprecedented flexibility in event
+ filtering. <code>GEventEvaluator</code> requires the Groovy
+ runtime. Please see the <a
+ href="../setup.html#gEventEvaluator">corresponding section</a> of
+ the setup document.
+ </p>
+
+ <p>Evaluation expressions are compiled on-the-fly during the
+ interpretation of the configuration file. As a user, you do not
+ need to worry about the actual plumbing. However, it is your
+ reponsibility to ensure that the groovy-language expression is
+ valid.
+ </p>
+
+ <p>The evaluation expression acts on the current logging event,
+ logback automatically inserts the current logging event of type <a
+ href="../apidocs/ch/qos/logback/classic/spi/ILoggingEvent.html">ILoggingEvent.</a>
+ as a variable called 'event' and its shorthand 'e'. The variables
+ TRACE, DEBUG, INFO, WARN and ERROR are also exported into the
+ scope of the expression. Thus, "event.level == DEBUG" is a valid
+ groovy expression which will return <code>true</code> only if the
+ current logging event's level is equal to DEBUG.
+ </p>
+
+ <p>Here is a more complete example.</p>
+
+<pre class="prettyprint source"><configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <b><filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator">
+ <expression>
+ e.level>=WARN
+ &amp;&amp; <!-- Stands for && in XML -->
+ !(e.mdc?.get("req.userAgent") ~= /Googlebot|msnbot|Yahoo/ )
+ </expression>
+ </evaluator>
+ <OnMismatch>DENY</OnMismatch>
+ <OnMatch>NEUTRAL</OnMatch>
+ </filter></b>
+ <encoder>
+ <pattern>
+ %-4relative [%thread] %-5level %logger - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <root level="DEBUG">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration></pre>
+
+
+ <p>The above filter will let events of level WARN and higher go
+ through onto the console unless the error is generated by Web
+ crawlers associated with Google, MSN or Yahoo. It does so by
+ checking whether the MDC associated with the event contains a
+ value for "req.userAgent" matching the
+ <code>/Googlebot|msnbot|Yahoo/</code> regular expression. Note
+ that since the mdc map can be null, we are also using Groovy's <a
+ href="http://groovy.codehaus.org/Null+Object+Pattern">safe
+ derefencing opeator</a>, that is the .? operator. The equivalent
+ logic would have be much longer to express in Java.
+ </p>
+
+ <p>If you are wondering how the identifier for the user agent was
+ inserted into the MDC under the 'req.userAgent' key, it behooves
+ us to mention that logback ships with a servlet filter named <a
+ href="mdc.html#mis"><code>MDCInsertingServletFilter</code></a>
+ designed for this purpose. It will be described in a later
+ chapter.
+ </p>
+
+ <!-- ==================== JaninoEventEvaluator ======================== -->
+
+ <h3><a name="JaninoEventEvaluator"
+ href="#JaninoEventEvaluator">JaninoEventEvaluator</a></h3>
+
+
+ <p>Logback-classic ships with another concrete
+ <code>EventEvaluator</code> implementation called <a
href="../xref/ch/qos/logback/classic/boolex/JaninoEventEvaluator.html">JaninoEventEvaluator</a>
- which takes artibtrary java language boolean expressions as the
+ which taking artibtrary java language boolean expressions as the
evaluation criteria. We refer to such java language boolean
expressions as "<em>evaulation expressions</em>". Evaluation
- expressions enable hereto unprecedented flexibility in event
- filtering. <code>JaninoEventEvaluator</code> requires the <a
+ expressions enable great flexibility in event
+ filtering.<code>JaninoEventEvaluator</code> requires the <a
href="http://docs.codehaus.org/display/JANINO/Home">Janino
library</a>. Please see the <a
href="../setup.html#janino">corresponding section</a> of the setup
- document.
+ document. Compared to <code>JaninoEventEvaluator</code>,
+ <code>GEventEvaluator</code>, by virtue of the Groovy language, is
+ significantly more convenient to use, but
+ <code>JaninoEventEvaluator</code> will usually run (much) faster
+ for equivalent expressions.
</p>
<p>Evaluation expressions are compiled on-the-fly during the
@@ -555,6 +656,10 @@ java chapters.filters.FilterEvents src/main/java/chapters/filters/basicConfigura
<p>In case you need to define additional matchers, you can do so by
adding further <code><matcher></code> elements.</p>
+
+
+
+
<!-- ================================================================ -->
<!-- ===================== TURBO FILTER ============================= -->
<!-- ================================================================ -->
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 70d1eed..398366a 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -38,6 +38,11 @@
by Ellen Strnod.
</p>
+ <p>Added <a
+ href="manual/filters.html#GEventEvaluator">GEventEvaluator</a>
+ which processes boolean expression written in the Groovy language.
+ </p>
+
<hr width="80%" align="center" />
diff --git a/logback-site/src/site/pages/setup.html b/logback-site/src/site/pages/setup.html
index 1b408c7..2922563 100644
--- a/logback-site/src/site/pages/setup.html
+++ b/logback-site/src/site/pages/setup.html
@@ -82,6 +82,16 @@
JavaMail</a>, you need to place <em>mail.jar</em> on your class
path.</p>
+
+ <h3><a name="gEventEvaluator"
+ href="#gEventEvaluator"><code>GEventEvaluator</code> requires the
+ Groovy runtime</a></h3>
+
+ <p><code>GEventEvaluator</code> depends on the Groovy runtime. It
+ was tested with Groovy version 1.7.2.
+ </p>
+
+
<h3><a name="janino" href="#janino">Evaluators and more
specifically <code>JaninoEvantEvaluator</code> require
Janino</a></h3>
diff --git a/pom.xml b/pom.xml
index eb436ae..88076fc 100755
--- a/pom.xml
+++ b/pom.xml
@@ -43,7 +43,7 @@
<properties>
<!-- slf4j.version property is used below, in
logback-classic/pom.xml and in setClasspath.cmd -->
- <slf4j.version>1.6.0-RC0</slf4j.version>
+ <slf4j.version>1.6.0-alpha2</slf4j.version>
<consolePlugin.version>1.1.0</consolePlugin.version>
</properties>
@@ -85,6 +85,11 @@
<version>2.5.10</version>
</dependency>
<dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.7.2</version>
+ </dependency>
+ <dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
-----------------------------------------------------------------------
Summary of changes:
logback-classic/pom.xml | 42 +++++-
.../classic/boolex/EvaluatorTemplate.groovy | 40 ++++++
.../logback/classic/boolex/GEventEvaluator.java | 86 ++++++++++++
.../IEvaluator.java} | 17 ++-
.../ch/qos/logback/classic/spi/ILoggingEvent.java | 7 +
.../ch/qos/logback/classic/spi/LoggingEvent.java | 4 +
.../ch/qos/logback/classic/spi/LoggingEventVO.java | 5 +-
.../java/org/slf4j/impl/StaticLoggerBinder.java | 2 +-
.../classic/boolex/GEventEvaluatorTest.java | 147 ++++++++++++++++++++
.../qos/logback/classic/spi/PubLoggingEventVO.java | 4 +
.../logback/core/boolex/EventEvaluatorBase.java | 1 -
.../ch/qos/logback/core/net/SMTPAppenderBase.java | 6 +-
.../java/ch/qos/logback/core/util/FileUtil.java | 52 ++++++-
logback-site/src/site/pages/manual/filters.html | 121 +++++++++++++++-
logback-site/src/site/pages/news.html | 5 +
logback-site/src/site/pages/setup.html | 10 ++
pom.xml | 7 +-
17 files changed, 521 insertions(+), 35 deletions(-)
create mode 100644 logback-classic/src/main/groovy/ch/qos/logback/classic/boolex/EvaluatorTemplate.groovy
create mode 100644 logback-classic/src/main/java/ch/qos/logback/classic/boolex/GEventEvaluator.java
copy logback-classic/src/main/java/ch/qos/logback/classic/{pattern/LoggerConverter.java => boolex/IEvaluator.java} (62%)
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/boolex/GEventEvaluatorTest.java
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0