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
March 2007
- 7 participants
- 175 discussions

svn commit: r1430 - in logback/trunk: logback-classic/src/main/java/ch/qos/logback/classic/joran/action logback-classic/src/test/input/joran logback-classic/src/test/java/ch/qos/logback/classic/joran logback-examples/src/main/java/chapter3
by noreply.seb@qos.ch 15 Mar '07
by noreply.seb@qos.ch 15 Mar '07
15 Mar '07
Author: seb
Date: Thu Mar 15 14:56:44 2007
New Revision: 1430
Added:
logback/trunk/logback-classic/src/test/input/joran/redirectToFile.xml
logback/trunk/logback-classic/src/test/input/joran/redirectToUrl.xml
logback/trunk/logback-examples/src/main/java/chapter3/includedConfig.xml
logback/trunk/logback-examples/src/main/java/chapter3/redirectConfig.xml
Removed:
logback/trunk/logback-classic/src/test/input/joran/redirectToInvalid.xml
logback/trunk/logback-classic/src/test/input/joran/redirectWithSubst.xml
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/IncludeFileAction.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/IncludeFileActionTest.java
Log:
Added url attribute to include element
Modified tests
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/IncludeFileAction.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/IncludeFileAction.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/IncludeFileAction.java Thu Mar 15 14:56:44 2007
@@ -12,6 +12,8 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
import org.xml.sax.Attributes;
@@ -26,56 +28,102 @@
private static final String INCLUDED_TAG = "included";
private static final String FILE_ATTR = "file";
- private SaxEventRecorder recorder;
-
+ private static final String URL_ATTR = "url";
+ private SaxEventRecorder recorder = new SaxEventRecorder();;
+
@Override
public void begin(InterpretationContext ec, String name, Attributes attributes)
throws ActionException {
- String attribute = attributes.getValue(FILE_ATTR);
- if (attribute == null) {
- addError("Path to configuration file to include is not set.");
+ String attFile = attributes.getValue(FILE_ATTR);
+ String attUrl = attributes.getValue(URL_ATTR);
+ // if both are null, report error and do nothing.
+ if (attFile == null && attUrl == null) {
+ addError("One of path and URL attribute must be set.");
return;
}
-
- String pathToFile;
-
- if (attribute.startsWith("$")) {
- pathToFile = ec.subst(attribute);
- } else {
- pathToFile = attribute;
+
+ String pathToFile = null;
+ if (attFile != null) {
+ if (attFile.startsWith("$")) {
+ pathToFile = ec.subst(attFile);
+ } else {
+ pathToFile = attFile;
+ }
+ }
+
+ URL urlToFile = null;
+ String tmpUrl;
+ if (attUrl != null) {
+ if (attUrl.startsWith("$")) {
+ tmpUrl = ec.subst(attUrl);
+ } else {
+ tmpUrl = attUrl;
+ }
+ try {
+ urlToFile = new URL(tmpUrl);
+ } catch (MalformedURLException mue) {
+ String errMsg = "URL [" + tmpUrl + "] is not well formed.";
+ addError(errMsg, mue);
+ return;
+ }
}
+ // we know now that either pathToFile or urlToFile
+ // is not null and correctly formed (in case of urlToFile).
+
try {
- InputStream in = new FileInputStream(pathToFile);
- parseAndRecord(in);
- in.close();
- } catch (IOException ioe) {
- String errMsg = "File [" + pathToFile + "] does not exist.";
- addError(errMsg, ioe);
+ InputStream in = getInputStream(pathToFile, urlToFile);
+ if (in != null) {
+ parseAndRecord(in);
+ in.close();
+ }
} catch (JoranException e) {
addError("Error while parsing file " + pathToFile + e);
+ } catch (IOException e) {
+ // called if in.close did not work
}
-
+
if (recorder.saxEventList.size() == 0) {
return;
}
-
+
+ //Let's remove the two <included> events before
+ //adding the events to the player.
SaxEvent first = recorder.saxEventList.get(0);
if (first != null && first.qName.equalsIgnoreCase(INCLUDED_TAG)) {
recorder.saxEventList.remove(0);
}
- SaxEvent last = recorder.saxEventList.get(recorder.saxEventList.size()-1);
+ SaxEvent last = recorder.saxEventList.get(recorder.saxEventList.size() - 1);
if (last != null && last.qName.equalsIgnoreCase(INCLUDED_TAG)) {
- recorder.saxEventList.remove(recorder.saxEventList.size()-1);
+ recorder.saxEventList.remove(recorder.saxEventList.size() - 1);
}
-
+
ec.getJoranInterpreter().addEvents(recorder.saxEventList);
}
-
+
+ private InputStream getInputStream(String pathToFile, URL urlToFile) {
+ if (pathToFile != null) {
+ try {
+ return new FileInputStream(pathToFile);
+ } catch (IOException ioe) {
+ String errMsg = "File [" + pathToFile + "] does not exist.";
+ addError(errMsg, ioe);
+ return null;
+ }
+ } else {
+ try {
+ return urlToFile.openStream();
+ } catch (IOException e) {
+ String errMsg = "URL [" + urlToFile.toString() + "] does not exist.";
+ addError(errMsg, e);
+ return null;
+ }
+ }
+ }
+
private void parseAndRecord(InputStream inputSource) throws JoranException {
- recorder = new SaxEventRecorder();
recorder.setContext(context);
recorder.recordEvents(inputSource);
}
Added: logback/trunk/logback-classic/src/test/input/joran/redirectToFile.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/redirectToFile.xml Thu Mar 15 14:56:44 2007
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration>
+
+<configuration>
+
+ <include file="${testing.value.file}" />
+
+</configuration>
Added: logback/trunk/logback-classic/src/test/input/joran/redirectToUrl.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/redirectToUrl.xml Thu Mar 15 14:56:44 2007
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration>
+
+<configuration>
+
+ <include url="${testing.value.url}" />
+
+</configuration>
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/IncludeFileActionTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/IncludeFileActionTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/IncludeFileActionTest.java Thu Mar 15 14:56:44 2007
@@ -10,20 +10,23 @@
import ch.qos.logback.core.ConsoleAppender;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.status.Status;
+import ch.qos.logback.core.util.StatusPrinter;
public class IncludeFileActionTest extends TestCase {
LoggerContext context;
IncludeFileAction action;
- String filePath = Constants.TEST_DIR_PREFIX
- + "input/joran/redirectConfig.xml";
- String invalidRedirect = Constants.TEST_DIR_PREFIX
- + "input/joran/invalidRedirect.xml";
- String filePathWithSubst = Constants.TEST_DIR_PREFIX
- + "input/joran/redirectWithSubst.xml";
- String redirectToInvalid = Constants.TEST_DIR_PREFIX
- + "input/joran/redirectToInvalid.xml";
+ String redirectToFile = Constants.TEST_DIR_PREFIX
+ + "input/joran/redirectToFile.xml";
+ String redirectToURL = Constants.TEST_DIR_PREFIX
+ + "input/joran/redirectToUrl.xml";
+
+ String urlConfig = "http://logback.qos.ch/simpleConfig.xml";
+ String simpleConfig = Constants.TEST_DIR_PREFIX
+ + "input/joran/simpleConfig.xml";
+ String invalidConfig = Constants.TEST_DIR_PREFIX
+ + "input/joran/invalidConfig.xml";
@Override
protected void setUp() throws Exception {
@@ -41,37 +44,63 @@
}
public void testLoadFileOK() throws JoranException {
+ System.setProperty("testing.value.file", simpleConfig);
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(context);
- jc.doConfigure(filePath);
+ jc.doConfigure(redirectToFile);
verifyConfig();
}
public void testNoFileFound() throws JoranException {
+ System.setProperty("testing.value.file", "toto");
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(context);
- jc.doConfigure(invalidRedirect);
+ jc.doConfigure(redirectToFile);
- assertEquals(3, context.getStatusManager().getCount());
+ assertEquals(2, context.getStatusManager().getCount());
assertEquals(Status.ERROR, context.getStatusManager().getLevel());
}
public void testWithCorruptFile() throws JoranException {
+ System.setProperty("testing.value.file", invalidConfig);
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(context);
- jc.doConfigure(redirectToInvalid);
+ jc.doConfigure(redirectToFile);
assertEquals(10, context.getStatusManager().getCount());
assertEquals(Status.ERROR, context.getStatusManager().getLevel());
}
- public void testWithSubst() throws JoranException {
+// public void testURLOK() throws JoranException {
+// //This one needs that we put a file on the web
+// //and requires a net connection on the test-runner's side.
+// System.setProperty("testing.value.url", urlConfig);
+// JoranConfigurator jc = new JoranConfigurator();
+// jc.setContext(context);
+// jc.doConfigure(redirectToURL);
+//
+// verifyConfig();
+// }
+
+ public void testMalformedURL() throws JoranException {
+ System.setProperty("testing.value.url", "htp://logback.qos.ch");
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(context);
- jc.doConfigure(filePathWithSubst);
+ jc.doConfigure(redirectToURL);
- verifyConfig();
+ assertEquals(2, context.getStatusManager().getCount());
+ assertEquals(Status.ERROR, context.getStatusManager().getLevel());
+ }
+
+ public void testUnknownURL() throws JoranException {
+ System.setProperty("testing.value.url", "http://logback2345.qos.ch");
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(context);
+ jc.doConfigure(redirectToURL);
+
+ assertEquals(2, context.getStatusManager().getCount());
+ assertEquals(Status.ERROR, context.getStatusManager().getLevel());
}
private void verifyConfig() {
Added: logback/trunk/logback-examples/src/main/java/chapter3/includedConfig.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-examples/src/main/java/chapter3/includedConfig.xml Thu Mar 15 14:56:44 2007
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<included>
+
+ <appender name="redirectConsole"
+ class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <param name="Pattern" value="%d - %m%n" />
+ </layout>
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender-ref ref="redirectConsole" />
+ </root>
+
+</included>
\ No newline at end of file
Added: logback/trunk/logback-examples/src/main/java/chapter3/redirectConfig.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-examples/src/main/java/chapter3/redirectConfig.xml Thu Mar 15 14:56:44 2007
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration>
+
+ <include file="path/to/included/configuration/file" />
+
+</configuration>
1
0

svn commit: r1429 - logback/trunk/logback-site/src/site/pages/manual
by noreply.ceki@qos.ch 14 Mar '07
by noreply.ceki@qos.ch 14 Mar '07
14 Mar '07
Author: ceki
Date: Wed Mar 14 22:32:01 2007
New Revision: 1429
Modified:
logback/trunk/logback-site/src/site/pages/manual/layouts.html
Log:
improved text, ongoing work
Modified: logback/trunk/logback-site/src/site/pages/manual/layouts.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/manual/layouts.html (original)
+++ logback/trunk/logback-site/src/site/pages/manual/layouts.html Wed Mar 14 22:32:01 2007
@@ -22,6 +22,14 @@
<h1>Chapter 5: Layouts</h1>
+ <div class="quote">
+ <p>TCP implementations will follow a general principle of
+ robustness: be conservative in what you do, be liberal in what
+ you accept from others.
+ </p>
+ <p>-- JON POSTEL, RFC 793</p>
+ </div>
+
<script src="../templates/creative.js"></script>
<div class="highlight">
@@ -935,23 +943,26 @@
</tr>
</table>
- <p>Here are some examples of the format modifier truncation:</p>
+ <p>The table below list examples for format modifier
+ truncation. Please note that the brackets, i.e the pair of "[]"
+ characters, are not part of the output. They are used to delimit
+ the width of output.</p>
<table class="bodyTable" BORDER="0" CELLPADDING="8">
<th>Format modifier</th>
<th>Logger name</th>
- <th>Result</th>
- <tr class="a">
- <td align="center">[%-20.20logger]</td>
- <td align="center">main.Name</td>
- <td align="center"><pre>[main.Name ]</pre></td>
- </tr>
+ <th>Result</th>
<tr class="b">
<td align="center">[%20.20logger]</td>
<td align="center">main.Name</td>
<td align="center"><pre>[ main.Name]</pre></td>
</tr>
+ <tr class="a">
+ <td align="center">[%-20.20logger]</td>
+ <td align="center">main.Name</td>
+ <td align="center"><pre>[main.Name ]</pre></td>
+ </tr>
<tr class="a">
<td align="center">[%10.10logger]</td>
<td align="center">main.foo.foo.bar.Name</td>
@@ -964,18 +975,20 @@
</tr>
</table>
- <h3>Option handling</h3>
+ <h3>Options</h3>
<p>
- A conversion specifier can be followed by options between
- braces. We have already seen some of the
- possibilities offered by logback's option handling with, for
- example, the MDC conversion specifier:
+ A conversion specifier can be followed by options. The are
+ always declared between braces. We have already seen some of the
+ possibilities offered by options, for instance in conjunction
+ with the MDC conversion specifier, as in:
<em>%mdc{someKey}</em>.
</p>
- <p>A conversion specifier might have more than one options. For example,
- a conversion specifier that uses evaluators, which we will cover very soon,
- simply adds the evaluator names to the option list, as shown below:</p>
+
+ <p>A conversion specifier might have more than one option. For
+ example, a conversion specifier that makes use of evaluators,
+ which will be covered soon, may add evaluator names to the option
+ list, as shown below:</p>
<div class="source"><pre>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
@@ -986,43 +999,30 @@
</appender></pre></div>
- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+ <h3>Evaluators</h3>
- <h4>Evaluators</h4>
- <p>
- Another use case for adding options to a conversion
- specifier is when
- <code>PatternLayout</code>
- is used with
- <a href="../xref/ch/qos/logback/core/boolex/EventEvaluator.html">
- <code>EventEvaluator</code></a> objects.
- </p>
- <p>
- <code>EventEvaluator</code> objects
- have the responsability to check wether a given event
- matches a given criteria.
- </p>
- <p>
- Let's look at an example using
- <code>EventEvaluator</code> objects.
- The following configuration file outputs the logging
- events to the console, displaying date, thread, level,
- message and caller data.
- </p>
- <p>
- Since displaying the caller data of a logging event is rather
- expensive, this information will be displayed only when the
- logging request comes from a specific logger, and whose
- message contains a certain string. By doing that, we make
- sure that only the specific logging requests will have
- their caller information generated and displayed, without
- penalizing application performance.
+ <p>As mentioned above, option lists come in handy when a
+ conversion specifier is required to behave dynamically based on
+ one or more
+ <a href="../xref/ch/qos/logback/core/boolex/EventEvaluator.html">
+ <code>EventEvaluator</code></a> objects.
+ <code>EventEvaluator</code> objects have the responsibility to
+ determine whether a given logging event matches the criteria of the
+ evaluator.
+ </p>
+
+ <p>Let us review an example with <code>EventEvaluator</code>
+ objects. The following configuration file outputs the logging
+ events to the console, displaying date, thread, level, message and
+ caller data. Given that extracting the caller data of a logging
+ event is on expensive side, we will do so only when the logging
+ request originates from a specific logger, and whose message
+ contains a certain string. Thus, we make sure that only specific
+ logging requests will have their caller information generated and
+ displayed. In other cases, where the caller data is superfluous,
+ we will not penalize application performance.
</p>
- <p>
- Here is how to configure logback to behave like we
- described:
- </p>
<em>
Example 5.2: Sample usage of EventEvaluators
(logback-examples/src/main/java/chapter5/callerEvaluatorConfig.xml)
@@ -1045,14 +1045,19 @@
<appender-ref ref="STDOUT" />
</root>
</configuration></pre></div>
- <p>Please note that the & value cannot be written like one would do in a java
- class, because of XML encoding rules.</p>
- <p>Let us test this configuration with the following code.</p>
- <em>
+
+ <p>Due to XML encoding rules, the & character cannot be
+ written as is, and needs to be escaped as &amp;.</p>
+
+ <p>The above configuration file is designed to be accompanied by
+ the following custom-tailored code.</p>
+
+ <p><em>
Example 5.2: Sample usage of EventEvaluators
<a href="../xref/chapter5/CallerEvaluatorExample.html">
(logback-examples/src/main/java/chapter5/CallerEvaluatorExample.java)</a>
</em>
+ </p>
<div class="source"><pre>package chapter5;
import org.slf4j.Logger;
@@ -1087,51 +1092,58 @@
}
}</pre></div>
<p>
- The above application does nothing too fancy. Five logging
- requests are issued, the third one being different from the
- others.
+ The <em>CallerEvaluatorExample</em> application does nothing particularly
+ fancy. Five logging requests are issued, the third one being
+ different from the others.
</p>
<p>
- When a logging request is sent, the corresponding logging event
- will pass through the evaluation process. Here, the third
- request will match the evaluation criteria, causing its caller
- data to be displayed.
+ When a logging request is issued, the corresponding logging
+ event goes through the evaluation process. The third request
+ matches the evaluation criteria, causing its caller data to be
+ displayed.
</p>
+
<p>
Here is the output of the
<code>CallerEvaluatorExample</code>
class.
</p>
+
<div class="source"><pre>0 [main] DEBUG - I know me 0
0 [main] DEBUG - I know me 1
0 [main] DEBUG - I know me 2
0 [main] DEBUG - who calls thee?
Caller+0 at chapter5.CallerEvaluatorExample.main(CallerEvaluatorExample.java:28)
-
0 [main] DEBUG - I know me 4</pre></div>
- <p>One can change the expression to match a real world
- situation. An expression testing logger name and request level
- could also be meaningful: all logging requests of level
- <em>WARN</em> and up, coming from a sensible part of an
- application like a financial transaction module, would have their
- caller data displayed.
+ <p>One can change the expression to correspond a real world
+ scenario. For instance, one could combine the logger name and
+ request level. Thus, logging requests of level <em>WARN</em> and
+ up, originating from a sensitive part of an application, e.g. a
+ financial transaction module, would have their caller data
+ displayed.
</p>
<p><b>Important:</b> With the <em>caller</em> conversion
specifier, the data is displayed when <em>the expression evaluates
to <b>true</b>.</em></p>
- <p>Now, let us look at a different situation. When exceptions are
+ <p>Let us consider at a different situation. When exceptions are
included in a logging request, their stack trace is usually
displayed. However, in some cases, one might want to supress the
- stack trace of specific exception.
+ stack trace of some specific exception.
</p>
- <p>The java code shown below creates five log requests, each one
- with an exception. However, we do not want to have the stack trace
- of the third request to be output.</p>
+ <p>The java code shown below creates five log requests, each with
+ an exception. However, it so happends that we do not wish the
+ stack trace of the third request to be output.</p>
+ <p><em>
+ Example 5.2: Sample usage of EventEvaluators
+ <a href="../xref/chapter5/ExceptionEvaluatorExample.html">
+ (logback-examples/src/main/java/chapter5/ExceptionEvaluatorExample.java)</a>
+ </em>
+ </p>
<div class="source"><pre>package chapter5;
import org.slf4j.Logger;
@@ -1166,7 +1178,8 @@
}
}</pre></div>
- <p>The following configuration will allow that.</p>
+ <p>The following configuration will supress the stack trace of the
+ third logging request.</p>
<em>
Example 5.3: Sample usage of EventEvaluators
(logback-examples/src/main/java/chapter5/exceptionEvaluatorConfig.xml)
@@ -1193,31 +1206,38 @@
</root>
</configuration></pre></div>
- <p>
- With this configuration, each time an instance of the
- <em>chapter5.TestException</em>
- is included within a logging request, no stack trace will be displayed.
+ <p>With this configuration, each time an instance of the
+ <em>chapter5.TestException</em> is included within a logging
+ request, the stack trace will be suppressed.
</p>
- <p><b>Important:</b> With the <b><em>%ex</em></b> conversion specifier, the data is
- displayed when <em>the expression evaluates to <b>false</b>.</em></p>
+
+ <p><b>Important:</b> With the <b><em>%ex</em></b> conversion
+ specifier, the stack trace is displayed when <em>the expression
+ evaluates to <b>false</b>.</em></p>
<h3>Creating a custom conversion specifier</h3>
- <p>We've seen up to here quite a lot of possibilities with conversion specifier and
- <code>PatternLayout</code> objects. But what if somebody wants to make her own conversion
- specifier?</p>
-
- <p>In that case, two steps are needed.</p>
-
- <p>First, one must implement her own <code>Converter</code>
- class. <a href="../xref/ch/qos/logback/core/pattern/Converter.html">
- <code>Converter</code></a> objects are responsible to extract a specific information out of
- a <code>LoggingEvent</code>. When <em>%logger</em> is used, a
- <a href="../xref/ch/qos/logback/classic/pattern/LoggerConverter.html">
- <code>LoggerConverter</code></a>
- is called to extract the name of the logger from the <code>LoggingEvent</code>.</p>
+
+ <p>Up to this point we have presented the built-inconversion
+ specifiers of <code>PatternLayout</code>. But it is also possible
+ to use a conversion specifier of your own making.</p>
+
+ <p>Building a custom conversion specifier consists of two steps.
+ </p>
- <p>Let us say that our customized <code>Converter</code> will output the level of the logging
- event, colored following ANSI rules. Here is the necessary implementation:</p>
+ <p>First, you must sub-class the <code>Converter</code> class. <a
+ href="../xref/ch/qos/logback/core/pattern/Converter.html">
+ <code>Converter</code></a> objects are responsible for extracting
+ information out of <code>LoggingEvent</code> objects and returning
+ it as String. For example, the
+ <a href="../xref/ch/qos/logback/classic/pattern/LoggerConverter.html">
+ <code>LoggerConverter</code></a>, the converter underlying the
+ %logger conversion word, extracts the name of the logger from the
+ <code>LoggingEvent</code> and returns it as a String. It might
+ abbreviate the logger name in the process.</p>
+
+ <p>Let us say that our customized <code>Converter</code> colors
+ the level of the logging event, according to ANSI terminal
+ conventions. Here is a possible implementation:</p>
<em> Example 5.4: Sample Converter Example
<a href="../xref/chapter5/MySampleConverter.html">
@@ -1261,14 +1281,19 @@
}
</pre></div>
- <p>This implementation is quite straightforward. The <code>MySampleConverter</code> class
- extends <code>ClassicConverter</code>, and implements the <code>convert</code> method.
- In that method, all it has to do is return the appropriate information.
+
+java chapter5.SampleLogging src/main/java/chapter5/mySampleConverterConfig.xml
+
+ <p>This implementation is relatively straightforward. The
+ <code>MySampleConverter</code> class extends
+ <code>ClassicConverter</code>, and implements the
+ <code>convert</code> method where it returns a level string
+ decorated with ANSI coloring codes.
</p>
- <p>The second step, once the <code>Converter</code> class done, is to let logback know about
- the new <code>Converter</code>. For this task, we just need to declare the new
- conversion word in the configuration file, as shown below:</p>
+ <p>In the second step, we must let logback know about the new
+ <code>Converter</code>. For this purpose, we need to declare the
+ new conversion word in the configuration file, as shown below:</p>
<em> Example 5.4: Sample Converter Example (src/main/java/chapter5/mySampleConverterConfig.xml)</em>
<div class="source"><pre><configuration>
@@ -1288,17 +1313,37 @@
</root>
</configuration></pre></div>
- <p>In this configuration file, once the new conversion word has been declared, we
- just use it within a <code>PatternLayout</code> pattern element, as if
- our custom conversion word had always been here.</p>
-
- <p>The intersted reader might want to take a look at other <code>Converter</code> implementations
- like
+ <p>In this configuration file, once the new conversion word has
+ been declared, we can refert to it within a
+ <code>PatternLayout</code> pattern, as if the custom conversion
+ word had always been here.</p>
+
+ <p>Given that ANSI terminal codes do not work on Windows, you can
+ view the results on non-Windows platforms such as Linux or
+ Mac. The following command:</p>
+
+ <div class="source">java chapter5.SampleLogging src/main/java/chapter5/mySampleConverterConfig.xml </div>
+
+ <p>should yield:</p>
+
+<div class="source">0 [main] DEBUG - Everything's going well
+3 [main] <span class="red">ERROR</span> - maybe not quite... </div>
+
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxx
+
+ <p>Please note that the string "ERROR" is highlighted in red,
+ which is basically the whole point of the exercise.</p>
+
+ <p>The intersted reader might want to take a look at other
+ <code>Converter</code> implementations such as
<a href="../xref/ch/qos/logback/classic/pattern/MDCConverter.html">
- <code>MDCConverter</code></a> to learn how to implement more complex behaviours, involving
- the use of options, in her custom <code>Converter</code> objects.
+ <code>MDCConverter</code></a> to learn how to implement more
+ complex behaviour, such as option handling.
</p>
+
+
+
<a name="ClassicHTMLLayout"></a>
<h3>HTMLLayout</h3>
<p><a href="../xref/ch/qos/logback/classic/html/HTMLLayout.html">
1
0
Online report : http://localhost:8090/continuum/servlet/continuum/target/ProjectBuild.vm/vi…
Build statistics:
State: Ok
Previous State: Failed
Started at: Wed, 14 Mar 2007 21:24:25 +0100
Finished at: Wed, 14 Mar 2007 21:24:47 +0100
Total time: 21s
Build Trigger: Forced
Exit code: 0
Building machine hostname: pixie
Operating system : Linux(unknown)
Java version : 1.5.0_08(Sun Microsystems Inc.)
Changes
No files changed
****************************************************************************
Output:
****************************************************************************
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Logback Classic Module
[INFO] task-segment: [clean, install]
[INFO] ----------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory /opt/continuum-1.0.3/apps/continuum/working-directory/46/target
[INFO] Deleting directory /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/classes
[INFO] Deleting directory /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/test-classes
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
Compiling 88 source files to /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/classes
[INFO] [retrotranslator:translate {execution: default}]
[INFO] Transforming 111 file(s) from /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/classes to /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/logback-classic-0.9.3-SNAPSHOT-jdk14.jar.
[INFO] Transformation of 111 file(s) completed successfully.
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
Compiling 89 source files to /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/test-classes
[INFO] [surefire:test]
[INFO] Surefire report directory: /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running ch.qos.logback.classic.LoggerContextTest
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.038 sec
Running ch.qos.logback.classic.pattern.ClassNameAbbreviatorTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.019 sec
Running ch.qos.logback.classic.pattern.MDCConverterTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.028 sec
Running ch.qos.logback.classic.PatternLayoutTest
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.033 sec
Running ch.qos.logback.classic.MessageFormattingTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.019 sec
Running ch.qos.logback.classic.LoggerTest
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.019 sec
Running ch.qos.logback.classic.pattern.ConverterTest
Tests run: 14, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.15 sec
Running ch.qos.logback.classic.selector.ContextJNDISelectorTest
MockInitialContextFactory static called
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.071 sec
Running ch.qos.logback.classic.control.TestAction
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.02 sec
Running ch.qos.logback.classic.DynamicLoggerContextTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.806 sec
Running ch.qos.logback.classic.util.InitializationTest
TEST 21:24:41.950 [main] DEBUG c.q.l.c.util.InitializationTest - Hello-didily-odily
TEST 21:24:41.951 [main] DEBUG c.q.l.c.util.InitializationTest - Hello-didily-odily
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec
Running ch.qos.logback.classic.db.DBAppenderTest
[Server@38dda25b]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@38dda25b]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@38dda25b]: [Thread[main,5,main]]: setDatabaseName(0,test)
[Server@38dda25b]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@38dda25b]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@38dda25b]: [Thread[main,5,main]]: setDatabasePath(0,mem:test;sql.enforce_strict_size=true)
[Server@485fcf29]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@485fcf29]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@485fcf29]: [Thread[main,5,main]]: setDatabaseName(0,test)
[Server@485fcf29]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@485fcf29]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@485fcf29]: [Thread[main,5,main]]: setDatabasePath(0,mem:test;sql.enforce_strict_size=true)
[Server@3af42ad0]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@3af42ad0]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@3af42ad0]: [Thread[main,5,main]]: setDatabaseName(0,test)
[Server@3af42ad0]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@3af42ad0]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@3af42ad0]: [Thread[main,5,main]]: setDatabasePath(0,mem:test;sql.enforce_strict_size=true)
[Server@67d95492]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@67d95492]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@67d95492]: [Thread[main,5,main]]: setDatabaseName(0,test)
[Server@67d95492]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@67d95492]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@67d95492]: [Thread[main,5,main]]: setDatabasePath(0,mem:test;sql.enforce_strict_size=true)
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.298 sec
Running ch.qos.logback.classic.joran.IncludeFileActionTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec
Running ch.qos.logback.classic.html.HTMLLayoutTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.598 sec
Running ch.qos.logback.classic.control.RandomUtilTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.03 sec
Running ch.qos.logback.classic.turbo.MarkerFilterTest
LOGBACK: No context given for ch.qos.logback.classic.turbo.MarkerFilter@2927fa12
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec
Running ch.qos.logback.classic.net.SocketAppenderTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.588 sec
Running ch.qos.logback.classic.control.ScenarioMakerTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.051 sec
Running ch.qos.logback.classic.net.LoggingEventSerializationTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.014 sec
Running ch.qos.logback.classic.control.CLCTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 sec
Running ch.qos.logback.classic.selector.ContextDetachingSCLTest
About to detach context named toto
No context named toto was found.
About to detach context named titi
TEST 21:24:44.607 [main] WARN root - Shutting down context titi
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 sec
Running ch.qos.logback.classic.MDCTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec
Running ch.qos.logback.classic.BasicLoggerTest
|-WARN in ch.qos.logback.core.read.ListAppender[null] - Attempted to append to non started appender [null].
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec
Running ch.qos.logback.classic.net.SMTPAppenderTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.35 sec
Running ch.qos.logback.classic.boolex.JaninoEventEvaluatorTest
Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.423 sec
Running ch.qos.logback.classic.joran.EvaluatorJoranTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.028 sec
Running ch.qos.logback.classic.spi.ContextListenerTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec
Running ch.qos.logback.classic.pattern.MarkerConverterTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.014 sec
Running ch.qos.logback.classic.net.JMSQueueAppenderTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 sec
Running ch.qos.logback.classic.net.JMSTopicAppenderTest
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.014 sec
Running ch.qos.logback.classic.net.SyslogAppenderTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.219 sec
Running ch.qos.logback.classic.joran.BasicJoranTest
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.read.ListAppender]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [LIST]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [LIST] from the object stack
|-INFO in ch.qos.logback.classic.joran.action.LevelAction - root level set to DEBUG
|-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [LIST] to Logger[root]
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.read.ListAppender]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [LIST]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [LIST] from the object stack
|-INFO in ch.qos.logback.classic.joran.action.LevelAction - ch.qos.logback.classic.joran level set to INFO
|-INFO in ch.qos.logback.classic.joran.action.LevelAction - root level set to DEBUG
|-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [LIST] to Logger[root]
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Ignoring debug attribute.
|-WARN in ch.qos.logback.classic.joran.action.EvaluatorAction - Assuming default evaluator class [ch.qos.logback.classic.boolex.JaninoEventEvaluator]
|-INFO in ch.qos.logback.classic.joran.action.EvaluatorAction - Adding evaluator named [helloEval] to the object stack
|-INFO in ch.qos.logback.core.joran.action.MatcherAction - matcher named as [m]
|-INFO in ch.qos.logback.core.joran.action.MatcherAction - Popping appender named [m] from the object stack
|-INFO in ch.qos.logback.classic.joran.action.EvaluatorAction - Starting evaluator named [helloEval]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.StringListAppender]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STR_LIST]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [STR_LIST] from the object stack
|-INFO in ch.qos.logback.classic.joran.action.LevelAction - root level set to DEBUG
|-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STR_LIST] to Logger[root]
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.041 sec
Results :
Tests run: 144, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar]
[INFO] Building jar: /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/logback-classic-0.9.3-SNAPSHOT.jar
[INFO] Preparing source:jar
[WARNING] Removing: jar from forked lifecycle, to prevent recursive invocation.
[INFO] No goals needed for project - skipping
[INFO] [source:jar {execution: default}]
[INFO] Building jar: /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/logback-classic-0.9.3-SNAPSHOT-sources.jar
[INFO] [jar:jar {execution: bundle-test-jar}]
[INFO] [jar:test-jar {execution: bundle-test-jar}]
[INFO] Building jar: /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/logback-classic-0.9.3-SNAPSHOT-tests.jar
[INFO] [install:install]
[INFO] Installing /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/logback-classic-0.9.3-SNAPSHOT.jar to /root/.m2/repository/ch/qos/logback/logback-classic/0.9.3-SNAPSHOT/logback-classic-0.9.3-SNAPSHOT.jar
[INFO] Installing /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/logback-classic-0.9.3-SNAPSHOT-sources.jar to /root/.m2/repository/ch/qos/logback/logback-classic/0.9.3-SNAPSHOT/logback-classic-0.9.3-SNAPSHOT-sources.jar
[INFO] Installing /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/logback-classic-0.9.3-SNAPSHOT-tests.jar to /root/.m2/repository/ch/qos/logback/logback-classic/0.9.3-SNAPSHOT/logback-classic-0.9.3-SNAPSHOT-tests.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20 seconds
[INFO] Finished at: Wed Mar 14 21:24:46 CET 2007
[INFO] Final Memory: 20M/199M
[INFO] ------------------------------------------------------------------------
****************************************************************************
1
0
Online report : http://localhost:8090/continuum/servlet/continuum/target/ProjectBuild.vm/vi…
Build statistics:
State: Failed
Previous State: Ok
Started at: Wed, 14 Mar 2007 21:20:18 +0100
Finished at: Wed, 14 Mar 2007 21:20:51 +0100
Total time: 32s
Build Trigger: Schedule
Exit code: 1
Building machine hostname: pixie
Operating system : Linux(unknown)
Java version : 1.5.0_08(Sun Microsystems Inc.)
Changes
seb Renamed LoadConfigurationFileAction.java to IncludeFileAction.java
Same for test class.
Renamed "path" attribute to "file"
/logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
/logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/IncludeFileAction.java (from /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoadConfigurationFileAction.java:1427)
/logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoadConfigurationFileAction.java
/logback/trunk/logback-classic/src/test/input/joran/invalidRedirect.xml
/logback/trunk/logback-classic/src/test/input/joran/redirectConfig.xml
/logback/trunk/logback-classic/src/test/input/joran/redirectToInvalid.xml
/logback/trunk/logback-classic/src/test/input/joran/redirectWithSubst.xml
/logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/IncludeFileActionTest.java (from /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/LoadConfigurationFileTest.java:1427)
/logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/LoadConfigurationFileTest.java
/logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
****************************************************************************
Output:
****************************************************************************
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Logback Classic Module
[INFO] task-segment: [clean, install]
[INFO] ----------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory /opt/continuum-1.0.3/apps/continuum/working-directory/46/target
[INFO] Deleting directory /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/classes
[INFO] Deleting directory /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/test-classes
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
Compiling 88 source files to /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/classes
[INFO] [retrotranslator:translate {execution: default}]
[INFO] Transforming 111 file(s) from /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/classes to /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/logback-classic-0.9.3-SNAPSHOT-jdk14.jar.
[INFO] Transformation of 111 file(s) completed successfully.
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
Compiling 89 source files to /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/test-classes
[INFO] [surefire:test]
[INFO] Surefire report directory: /opt/continuum-1.0.3/apps/continuum/working-directory/46/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running ch.qos.logback.classic.LoggerContextTest
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.15 sec
Running ch.qos.logback.classic.pattern.ClassNameAbbreviatorTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec
Running ch.qos.logback.classic.pattern.MDCConverterTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec
Running ch.qos.logback.classic.PatternLayoutTest
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.03 sec
Running ch.qos.logback.classic.MessageFormattingTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 sec
Running ch.qos.logback.classic.LoggerTest
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.02 sec
Running ch.qos.logback.classic.pattern.ConverterTest
Tests run: 14, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.147 sec
Running ch.qos.logback.classic.selector.ContextJNDISelectorTest
MockInitialContextFactory static called
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.038 sec
Running ch.qos.logback.classic.control.TestAction
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
Running ch.qos.logback.classic.DynamicLoggerContextTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.664 sec
Running ch.qos.logback.classic.util.InitializationTest
TEST 21:20:40.424 [main] DEBUG c.q.l.c.util.InitializationTest - Hello-didily-odily
TEST 21:20:40.425 [main] DEBUG c.q.l.c.util.InitializationTest - Hello-didily-odily
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
Running ch.qos.logback.classic.db.DBAppenderTest
[Server@2d5253d5]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@2d5253d5]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@2d5253d5]: [Thread[main,5,main]]: setDatabaseName(0,test)
[Server@2d5253d5]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@2d5253d5]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@2d5253d5]: [Thread[main,5,main]]: setDatabasePath(0,mem:test;sql.enforce_strict_size=true)
[Server@3af42ad0]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@3af42ad0]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@3af42ad0]: [Thread[main,5,main]]: setDatabaseName(0,test)
[Server@3af42ad0]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@3af42ad0]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@3af42ad0]: [Thread[main,5,main]]: setDatabasePath(0,mem:test;sql.enforce_strict_size=true)
[Server@6076ab2f]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@6076ab2f]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@6076ab2f]: [Thread[main,5,main]]: setDatabaseName(0,test)
[Server@6076ab2f]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@6076ab2f]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@6076ab2f]: [Thread[main,5,main]]: setDatabasePath(0,mem:test;sql.enforce_strict_size=true)
[Server@e49d67c]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@e49d67c]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@e49d67c]: [Thread[main,5,main]]: setDatabaseName(0,test)
[Server@e49d67c]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@e49d67c]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@e49d67c]: [Thread[main,5,main]]: setDatabasePath(0,mem:test;sql.enforce_strict_size=true)
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.883 sec
Running ch.qos.logback.classic.joran.IncludeFileActionTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.056 sec
Running ch.qos.logback.classic.html.HTMLLayoutTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.946 sec
Running ch.qos.logback.classic.control.RandomUtilTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.058 sec
Running ch.qos.logback.classic.turbo.MarkerFilterTest
LOGBACK: No context given for ch.qos.logback.classic.turbo.MarkerFilter@356f144c
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec
Running ch.qos.logback.classic.net.SocketAppenderTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.895 sec
Running ch.qos.logback.classic.control.ScenarioMakerTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.036 sec
Running ch.qos.logback.classic.net.LoggingEventSerializationTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec
Running ch.qos.logback.classic.control.CLCTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
Running ch.qos.logback.classic.selector.ContextDetachingSCLTest
About to detach context named toto
No context named toto was found.
About to detach context named titi
TEST 21:20:43.344 [main] WARN root - Shutting down context titi
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.014 sec
Running ch.qos.logback.classic.MDCTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.022 sec
Running ch.qos.logback.classic.BasicLoggerTest
|-WARN in ch.qos.logback.core.read.ListAppender[null] - Attempted to append to non started appender [null].
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec
Running ch.qos.logback.classic.net.SMTPAppenderTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.435 sec
Running ch.qos.logback.classic.boolex.JaninoEventEvaluatorTest
Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.515 sec
Running ch.qos.logback.classic.joran.EvaluatorJoranTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.044 sec
Running ch.qos.logback.classic.spi.ContextListenerTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec
Running ch.qos.logback.classic.pattern.MarkerConverterTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.019 sec
Running ch.qos.logback.classic.net.JMSQueueAppenderTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.035 sec
Running ch.qos.logback.classic.net.JMSTopicAppenderTest
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 sec
Running ch.qos.logback.classic.net.SyslogAppenderTest
java.net.BindException: Address already in use
at java.net.PlainDatagramSocketImpl.bind0(Native Method)
at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82)
at java.net.DatagramSocket.bind(DatagramSocket.java:368)
at java.net.DatagramSocket.<init>(DatagramSocket.java:210)
at java.net.DatagramSocket.<init>(DatagramSocket.java:261)
at java.net.DatagramSocket.<init>(DatagramSocket.java:234)
at ch.qos.logback.classic.net.mock.MockSyslogServer.run(MockSyslogServer.java:42)
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 6.158 sec <<< FAILURE!
Running ch.qos.logback.classic.joran.BasicJoranTest
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.read.ListAppender]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [LIST]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [LIST] from the object stack
|-INFO in ch.qos.logback.classic.joran.action.LevelAction - root level set to DEBUG
|-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [LIST] to Logger[root]
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.read.ListAppender]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [LIST]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [LIST] from the object stack
|-INFO in ch.qos.logback.classic.joran.action.LevelAction - ch.qos.logback.classic.joran level set to INFO
|-INFO in ch.qos.logback.classic.joran.action.LevelAction - root level set to DEBUG
|-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [LIST] to Logger[root]
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Ignoring debug attribute.
|-WARN in ch.qos.logback.classic.joran.action.EvaluatorAction - Assuming default evaluator class [ch.qos.logback.classic.boolex.JaninoEventEvaluator]
|-INFO in ch.qos.logback.classic.joran.action.EvaluatorAction - Adding evaluator named [helloEval] to the object stack
|-INFO in ch.qos.logback.core.joran.action.MatcherAction - matcher named as [m]
|-INFO in ch.qos.logback.core.joran.action.MatcherAction - Popping appender named [m] from the object stack
|-INFO in ch.qos.logback.classic.joran.action.EvaluatorAction - Starting evaluator named [helloEval]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.StringListAppender]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STR_LIST]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [STR_LIST] from the object stack
|-INFO in ch.qos.logback.classic.joran.action.LevelAction - root level set to DEBUG
|-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STR_LIST] to Logger[root]
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.119 sec
Results :
Tests run: 144, Failures: 1, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29 seconds
[INFO] Finished at: Wed Mar 14 21:20:50 CET 2007
[INFO] Final Memory: 18M/193M
[INFO] ------------------------------------------------------------------------
****************************************************************************
1
0

svn commit: r1428 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic/joran main/java/ch/qos/logback/classic/joran/action test/input/joran test/java/ch/qos/logback/classic/joran
by noreply.seb@qos.ch 14 Mar '07
by noreply.seb@qos.ch 14 Mar '07
14 Mar '07
Author: seb
Date: Wed Mar 14 21:16:21 2007
New Revision: 1428
Added:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/IncludeFileAction.java
- copied, changed from r1427, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoadConfigurationFileAction.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/IncludeFileActionTest.java
- copied, changed from r1427, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/LoadConfigurationFileTest.java
Removed:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoadConfigurationFileAction.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/LoadConfigurationFileTest.java
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
logback/trunk/logback-classic/src/test/input/joran/invalidRedirect.xml
logback/trunk/logback-classic/src/test/input/joran/redirectConfig.xml
logback/trunk/logback-classic/src/test/input/joran/redirectToInvalid.xml
logback/trunk/logback-classic/src/test/input/joran/redirectWithSubst.xml
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
Log:
Renamed LoadConfigurationFileAction.java to IncludeFileAction.java
Same for test class.
Renamed "path" attribute to "file"
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java Wed Mar 14 21:16:21 2007
@@ -15,7 +15,7 @@
import ch.qos.logback.classic.joran.action.JMXConfiguratorAction;
import ch.qos.logback.classic.joran.action.LayoutAction;
import ch.qos.logback.classic.joran.action.LevelAction;
-import ch.qos.logback.classic.joran.action.LoadConfigurationFileAction;
+import ch.qos.logback.classic.joran.action.IncludeFileAction;
import ch.qos.logback.classic.joran.action.LoggerAction;
import ch.qos.logback.classic.joran.action.RootLoggerAction;
import ch.qos.logback.core.joran.JoranConfiguratorBase;
@@ -59,7 +59,7 @@
new LayoutAction());
rs.addRule(new Pattern("configuration/jmxConfigurator"), new JMXConfiguratorAction());
- rs.addRule(new Pattern("configuration/include"), new LoadConfigurationFileAction());
+ rs.addRule(new Pattern("configuration/include"), new IncludeFileAction());
}
}
Copied: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/IncludeFileAction.java (from r1427, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoadConfigurationFileAction.java)
==============================================================================
--- /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoadConfigurationFileAction.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/IncludeFileAction.java Wed Mar 14 21:16:21 2007
@@ -22,17 +22,17 @@
import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.JoranException;
-public class LoadConfigurationFileAction extends Action {
+public class IncludeFileAction extends Action {
private static final String INCLUDED_TAG = "included";
- private static final String PATH_ATTR = "path";
+ private static final String FILE_ATTR = "file";
private SaxEventRecorder recorder;
@Override
public void begin(InterpretationContext ec, String name, Attributes attributes)
throws ActionException {
- String attribute = attributes.getValue(PATH_ATTR);
+ String attribute = attributes.getValue(FILE_ATTR);
if (attribute == null) {
addError("Path to configuration file to include is not set.");
return;
Modified: logback/trunk/logback-classic/src/test/input/joran/invalidRedirect.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/joran/invalidRedirect.xml (original)
+++ logback/trunk/logback-classic/src/test/input/joran/invalidRedirect.xml Wed Mar 14 21:16:21 2007
@@ -3,6 +3,6 @@
<configuration>
- <include path="toto" />
+ <include file="toto" />
</configuration>
Modified: logback/trunk/logback-classic/src/test/input/joran/redirectConfig.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/joran/redirectConfig.xml (original)
+++ logback/trunk/logback-classic/src/test/input/joran/redirectConfig.xml Wed Mar 14 21:16:21 2007
@@ -3,6 +3,6 @@
<configuration>
- <include path="src/test/input/joran/simpleConfig.xml" />
+ <include file="src/test/input/joran/simpleConfig.xml" />
</configuration>
Modified: logback/trunk/logback-classic/src/test/input/joran/redirectToInvalid.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/joran/redirectToInvalid.xml (original)
+++ logback/trunk/logback-classic/src/test/input/joran/redirectToInvalid.xml Wed Mar 14 21:16:21 2007
@@ -3,6 +3,6 @@
<configuration>
- <include path="src/test/input/joran/invalidConfig.xml" />
+ <include file="src/test/input/joran/invalidConfig.xml" />
</configuration>
Modified: logback/trunk/logback-classic/src/test/input/joran/redirectWithSubst.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/joran/redirectWithSubst.xml (original)
+++ logback/trunk/logback-classic/src/test/input/joran/redirectWithSubst.xml Wed Mar 14 21:16:21 2007
@@ -5,6 +5,6 @@
<substitutionProperty name="path.to.file"
value="src/test/input/joran/simpleConfig.xml" />
- <include path="${path.to.file}" />
+ <include file="${path.to.file}" />
</configuration>
Copied: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/IncludeFileActionTest.java (from r1427, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/LoadConfigurationFileTest.java)
==============================================================================
--- /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/LoadConfigurationFileTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/IncludeFileActionTest.java Wed Mar 14 21:16:21 2007
@@ -4,17 +4,17 @@
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;
-import ch.qos.logback.classic.joran.action.LoadConfigurationFileAction;
+import ch.qos.logback.classic.joran.action.IncludeFileAction;
import ch.qos.logback.classic.util.Constants;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.ConsoleAppender;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.status.Status;
-public class LoadConfigurationFileTest extends TestCase {
+public class IncludeFileActionTest extends TestCase {
LoggerContext context;
- LoadConfigurationFileAction action;
+ IncludeFileAction action;
String filePath = Constants.TEST_DIR_PREFIX
+ "input/joran/redirectConfig.xml";
@@ -29,7 +29,7 @@
protected void setUp() throws Exception {
super.setUp();
context = new LoggerContext();
- action = new LoadConfigurationFileAction();
+ action = new IncludeFileAction();
action.setContext(context);
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java Wed Mar 14 21:16:21 2007
@@ -17,7 +17,7 @@
TestSuite suite = new TestSuite();
suite.addTestSuite(BasicJoranTest.class);
suite.addTestSuite(EvaluatorJoranTest.class);
- suite.addTestSuite(LoadConfigurationFileTest.class);
+ suite.addTestSuite(IncludeFileActionTest.class);
return suite;
}
}
\ No newline at end of file
1
0

14 Mar '07
Author: seb
Date: Wed Mar 14 20:44:42 2007
New Revision: 1427
Added:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoadConfigurationFileAction.java
logback/trunk/logback-classic/src/test/input/joran/invalidConfig.xml
logback/trunk/logback-classic/src/test/input/joran/invalidRedirect.xml
logback/trunk/logback-classic/src/test/input/joran/redirectConfig.xml
logback/trunk/logback-classic/src/test/input/joran/redirectToInvalid.xml
logback/trunk/logback-classic/src/test/input/joran/redirectWithSubst.xml
logback/trunk/logback-classic/src/test/input/joran/simpleConfig.xml
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/LoadConfigurationFileTest.java
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
Log:
Added include functionality to Joran.
The <include> pattern used in a <configuration> pattern can have a "path" attribute with the path to a file that will be parsed and executed to configure logback.
This attribute can be set with a property.
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java Wed Mar 14 20:44:42 2007
@@ -15,6 +15,7 @@
import ch.qos.logback.classic.joran.action.JMXConfiguratorAction;
import ch.qos.logback.classic.joran.action.LayoutAction;
import ch.qos.logback.classic.joran.action.LevelAction;
+import ch.qos.logback.classic.joran.action.LoadConfigurationFileAction;
import ch.qos.logback.classic.joran.action.LoggerAction;
import ch.qos.logback.classic.joran.action.RootLoggerAction;
import ch.qos.logback.core.joran.JoranConfiguratorBase;
@@ -58,6 +59,7 @@
new LayoutAction());
rs.addRule(new Pattern("configuration/jmxConfigurator"), new JMXConfiguratorAction());
+ rs.addRule(new Pattern("configuration/include"), new LoadConfigurationFileAction());
}
}
Added: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoadConfigurationFileAction.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoadConfigurationFileAction.java Wed Mar 14 20:44:42 2007
@@ -0,0 +1,88 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ *
+ * Copyright (C) 1999-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.classic.joran.action;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.xml.sax.Attributes;
+
+import ch.qos.logback.core.joran.action.Action;
+import ch.qos.logback.core.joran.event.SaxEvent;
+import ch.qos.logback.core.joran.event.SaxEventRecorder;
+import ch.qos.logback.core.joran.spi.ActionException;
+import ch.qos.logback.core.joran.spi.InterpretationContext;
+import ch.qos.logback.core.joran.spi.JoranException;
+
+public class LoadConfigurationFileAction extends Action {
+
+ private static final String INCLUDED_TAG = "included";
+ private static final String PATH_ATTR = "path";
+ private SaxEventRecorder recorder;
+
+ @Override
+ public void begin(InterpretationContext ec, String name, Attributes attributes)
+ throws ActionException {
+
+ String attribute = attributes.getValue(PATH_ATTR);
+ if (attribute == null) {
+ addError("Path to configuration file to include is not set.");
+ return;
+ }
+
+ String pathToFile;
+
+ if (attribute.startsWith("$")) {
+ pathToFile = ec.subst(attribute);
+ } else {
+ pathToFile = attribute;
+ }
+
+ try {
+ InputStream in = new FileInputStream(pathToFile);
+ parseAndRecord(in);
+ in.close();
+ } catch (IOException ioe) {
+ String errMsg = "File [" + pathToFile + "] does not exist.";
+ addError(errMsg, ioe);
+ } catch (JoranException e) {
+ addError("Error while parsing file " + pathToFile + e);
+ }
+
+ if (recorder.saxEventList.size() == 0) {
+ return;
+ }
+
+ SaxEvent first = recorder.saxEventList.get(0);
+ if (first != null && first.qName.equalsIgnoreCase(INCLUDED_TAG)) {
+ recorder.saxEventList.remove(0);
+ }
+
+ SaxEvent last = recorder.saxEventList.get(recorder.saxEventList.size()-1);
+ if (last != null && last.qName.equalsIgnoreCase(INCLUDED_TAG)) {
+ recorder.saxEventList.remove(recorder.saxEventList.size()-1);
+ }
+
+ ec.getJoranInterpreter().addEvents(recorder.saxEventList);
+ }
+
+ private void parseAndRecord(InputStream inputSource) throws JoranException {
+ recorder = new SaxEventRecorder();
+ recorder.setContext(context);
+ recorder.recordEvents(inputSource);
+ }
+
+ @Override
+ public void end(InterpretationContext ec, String name) throws ActionException {
+ // do nothing
+ }
+
+}
Added: logback/trunk/logback-classic/src/test/input/joran/invalidConfig.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/invalidConfig.xml Wed Mar 14 20:44:42 2007
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE included>
+
+<included>
+ <!-- This file is invalid on purpose. Do not correct it. -->
+
+ <appender name="redirectConsole"
+ class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <param name="Pattern" value="%d - %m%n" />
+ </layout>
+
+
+ <root>
+ <level value="DEBUG" />
+ <appender-ref ref="redirectConsole" />
+ </root>
+
+</included>
\ No newline at end of file
Added: logback/trunk/logback-classic/src/test/input/joran/invalidRedirect.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/invalidRedirect.xml Wed Mar 14 20:44:42 2007
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration>
+
+<configuration>
+
+ <include path="toto" />
+
+</configuration>
Added: logback/trunk/logback-classic/src/test/input/joran/redirectConfig.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/redirectConfig.xml Wed Mar 14 20:44:42 2007
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration>
+
+<configuration>
+
+ <include path="src/test/input/joran/simpleConfig.xml" />
+
+</configuration>
Added: logback/trunk/logback-classic/src/test/input/joran/redirectToInvalid.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/redirectToInvalid.xml Wed Mar 14 20:44:42 2007
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration>
+
+<configuration>
+
+ <include path="src/test/input/joran/invalidConfig.xml" />
+
+</configuration>
Added: logback/trunk/logback-classic/src/test/input/joran/redirectWithSubst.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/redirectWithSubst.xml Wed Mar 14 20:44:42 2007
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration>
+
+<configuration>
+ <substitutionProperty name="path.to.file"
+ value="src/test/input/joran/simpleConfig.xml" />
+
+ <include path="${path.to.file}" />
+
+</configuration>
Added: logback/trunk/logback-classic/src/test/input/joran/simpleConfig.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/simpleConfig.xml Wed Mar 14 20:44:42 2007
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE included>
+
+<included>
+
+ <appender name="redirectConsole"
+ class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <param name="Pattern" value="%d - %m%n" />
+ </layout>
+ </appender>
+
+ <root>
+ <level value="DEBUG" />
+ <appender-ref ref="redirectConsole" />
+ </root>
+
+</included>
\ No newline at end of file
Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/LoadConfigurationFileTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/LoadConfigurationFileTest.java Wed Mar 14 20:44:42 2007
@@ -0,0 +1,85 @@
+package ch.qos.logback.classic.joran;
+
+import junit.framework.TestCase;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.PatternLayout;
+import ch.qos.logback.classic.joran.action.LoadConfigurationFileAction;
+import ch.qos.logback.classic.util.Constants;
+import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.ConsoleAppender;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.status.Status;
+
+public class LoadConfigurationFileTest extends TestCase {
+
+ LoggerContext context;
+ LoadConfigurationFileAction action;
+
+ String filePath = Constants.TEST_DIR_PREFIX
+ + "input/joran/redirectConfig.xml";
+ String invalidRedirect = Constants.TEST_DIR_PREFIX
+ + "input/joran/invalidRedirect.xml";
+ String filePathWithSubst = Constants.TEST_DIR_PREFIX
+ + "input/joran/redirectWithSubst.xml";
+ String redirectToInvalid = Constants.TEST_DIR_PREFIX
+ + "input/joran/redirectToInvalid.xml";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ context = new LoggerContext();
+ action = new LoadConfigurationFileAction();
+ action.setContext(context);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ action = null;
+ context = null;
+ }
+
+ public void testLoadFileOK() throws JoranException {
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(context);
+ jc.doConfigure(filePath);
+
+ verifyConfig();
+ }
+
+ public void testNoFileFound() throws JoranException {
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(context);
+ jc.doConfigure(invalidRedirect);
+
+ assertEquals(3, context.getStatusManager().getCount());
+ assertEquals(Status.ERROR, context.getStatusManager().getLevel());
+ }
+
+ public void testWithCorruptFile() throws JoranException {
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(context);
+ jc.doConfigure(redirectToInvalid);
+
+ assertEquals(10, context.getStatusManager().getCount());
+ assertEquals(Status.ERROR, context.getStatusManager().getLevel());
+ }
+
+ public void testWithSubst() throws JoranException {
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(context);
+ jc.doConfigure(filePathWithSubst);
+
+ verifyConfig();
+ }
+
+ private void verifyConfig() {
+ Logger logger = context.getLogger(LoggerContext.ROOT_NAME);
+ Appender appender = (ConsoleAppender) logger.getAppender("redirectConsole");
+ assertNotNull(appender);
+ PatternLayout layout = (PatternLayout) appender.getLayout();
+ assertNotNull(layout);
+ assertEquals("%d - %m%n", layout.getPattern());
+ }
+}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/PackageTest.java Wed Mar 14 20:44:42 2007
@@ -17,7 +17,7 @@
TestSuite suite = new TestSuite();
suite.addTestSuite(BasicJoranTest.class);
suite.addTestSuite(EvaluatorJoranTest.class);
-
+ suite.addTestSuite(LoadConfigurationFileTest.class);
return suite;
}
}
\ No newline at end of file
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java Wed Mar 14 20:44:42 2007
@@ -85,7 +85,6 @@
InterpretationContext ec = interpreter.getExecutionContext();
ec.setContext(context);
addImplicitRules(interpreter);
-
}
final public void doConfigure(final InputSource inputSource)
@@ -94,8 +93,7 @@
recorder.setContext(context);
recorder.recordEvents(inputSource);
buildInterpreter();
- EventPlayer player = new EventPlayer(interpreter);
- player.play(recorder.saxEventList);
+ interpreter.play(recorder.saxEventList);
}
public void doConfigure(final List<SaxEvent> eventList)
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/EventPlayer.java Wed Mar 14 20:44:42 2007
@@ -19,14 +19,19 @@
public class EventPlayer {
final Interpreter interpreter;
-
+ List<SaxEvent> eventList;
+ int currentIndex;
+
public EventPlayer(Interpreter interpreter) {
- this.interpreter = interpreter;
+ this.interpreter = interpreter;
}
public void play(List<SaxEvent> seList) {
-
- for(SaxEvent se : seList) {
+ eventList = seList;
+ SaxEvent se;
+ for(currentIndex = 0; currentIndex < eventList.size(); currentIndex++) {
+ se = eventList.get(currentIndex);
+
if(se instanceof StartEvent) {
interpreter.startElement((StartEvent) se);
// invoke fireInPlay after startElement processing
@@ -45,4 +50,8 @@
}
}
+
+ public void addEvents(List<SaxEvent> eventList) {
+ this.eventList.addAll(currentIndex+2, eventList);
+ }
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/Interpreter.java Wed Mar 14 20:44:42 2007
@@ -23,6 +23,7 @@
import ch.qos.logback.core.joran.action.ImplicitAction;
import ch.qos.logback.core.joran.event.BodyEvent;
import ch.qos.logback.core.joran.event.EndEvent;
+import ch.qos.logback.core.joran.event.SaxEvent;
import ch.qos.logback.core.joran.event.StartEvent;
import ch.qos.logback.core.spi.ContextAwareImpl;
@@ -68,6 +69,7 @@
final private ContextAwareImpl cai;
Pattern pattern;
Locator locator;
+ EventPlayer player;
/**
* The <id>actionListStack</id> contains a list of actions that are executing
@@ -93,6 +95,7 @@
implicitActions = new ArrayList<ImplicitAction>(3);
pattern = new Pattern();
actionListStack = new Stack<List>();
+ player = new EventPlayer(this);
}
public InterpretationContext getExecutionContext() {
@@ -328,4 +331,14 @@
public RuleStore getRuleStore() {
return ruleStore;
}
+
+ public void play(List<SaxEvent> eventList) {
+ player.play(eventList);
+ }
+
+ public void addEvents(List<SaxEvent> eventList) {
+ if (player != null) {
+ player.addEvents(eventList);
+ }
+ }
}
1
0

svn commit: r1426 - in logback/trunk/logback-site/src/site/pages: . css
by noreply.ceki@qos.ch 14 Mar '07
by noreply.ceki@qos.ch 14 Mar '07
14 Mar '07
Author: ceki
Date: Wed Mar 14 20:42:57 2007
New Revision: 1426
Modified:
logback/trunk/logback-site/src/site/pages/css/site.css
logback/trunk/logback-site/src/site/pages/dependencies.html
Log:
minor updates
Modified: logback/trunk/logback-site/src/site/pages/css/site.css
==============================================================================
--- logback/trunk/logback-site/src/site/pages/css/site.css (original)
+++ logback/trunk/logback-site/src/site/pages/css/site.css Wed Mar 14 20:42:57 2007
@@ -63,26 +63,21 @@
h1, h2, h3, h4 {
color: #333;
+ padding-top: 0ex;
+ background-color: transparent;
}
h2 {
- padding-top: 0ex;
- background-color: transparent;
font-weight: 900;
font-size: x-large;
}
h3 {
- padding-top: 0ex;
- background-color: transparent;
font-weight: normal;
font-size: large;
}
h4 {
- padding-top: 0ex;
- color: navy;
- background-color: transparent;
font-weight: large;
font-size: normal;
}
@@ -137,6 +132,7 @@
padding: 0px;
border: 1px solid #cccccc;
background-color: #ffffff;
+ font-size: 80%;
}
#left a, #right a {
@@ -170,7 +166,7 @@
#content {
- margin: 0px 17em 0px 17em;
+ margin: 0px 15em 0px 15em;
padding: 0px;
background-color: #ffffff;
}
@@ -178,12 +174,13 @@
#right {
position: absolute;
right: 0px;
- width: 14em;
+ width: 12em;
color: #564b47;
margin: 4px 4px 0px 0px;
padding: 0px;
background-color: #ffffff;
border: 1px solid #cccccc;
+ font-size: 80%;
}
#left img {
@@ -296,3 +293,8 @@
margin-left: 3em;
margin-right: 3em;
}
+
+.quote {
+ align: right;
+ padding-left: 12em;
+}
\ No newline at end of file
Modified: logback/trunk/logback-site/src/site/pages/dependencies.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/dependencies.html (original)
+++ logback/trunk/logback-site/src/site/pages/dependencies.html Wed Mar 14 20:42:57 2007
@@ -55,13 +55,22 @@
</ul>
</td>
</tr>
- <tr class="b">
- <td>SMTPAppender</td>
+ <tr class="a">
+ <td><code>JaninoEventEvaluatorBase</code> and derived classes</td>
<td>
<ul>
+ <li><a href="http://janino.net">Janino</a> version 2.4.3</li>
+ </ul>
+ </td>
+ </tr>
+
+ <tr class="b">
+ <td><code>SMTPAppenderBase</code> and derived classes</td>
+ <td>
+ <ul>
<li><a
href="https://glassfish.dev.java.net/javaee5/mail/">JavaMail
- API</a> version 1.4,
+ API</a> version 1.4,
</li>
<li><a
href="http://java.sun.com/products/javabeans/jaf/index.jsp">JavaBeans
@@ -70,14 +79,7 @@
</ul>
</td>
</tr>
- <tr class="a">
- <td>JaninoEventEvaluatorBase and derived classes</td>
- <td>
- <ul>
- <li><a href="http://janino.net">Janino</a> version 2.4.3</li>
- </ul>
- </td>
- </tr>
+
</table>
<h2>logback-classic</h2>
@@ -131,6 +133,37 @@
</ul>
</td>
</tr>
+
+ <tr class="b">
+ <td>c.q.l.c.boolex.JaninoEventEvaluator</td>
+ <td>
+ <ul>
+ <li>Depends on <code>JaninoEventEvaluatorBase</code>, and by
+ transitivity on <code>JaninoEventEvaluatorBase</code>'s
+ dependencies.
+ </li>
+ </ul>
+ </td>
+ </tr>
+
+ <tr class="b">
+ <td>SMTPAppender</td>
+ <td>
+ <ul>
+ <li>Depends on <code>SMTPAppenderBase</code>, and by
+ transitivity on <code>SMTPAppenderBase</code>'s
+ dependencies.
+ </li>
+
+ <li>Depends on
+ <code>ch.qos.logback.classic.boolex.JaninoEventEvaluator</code>,
+ and by transitivity on Janino.
+ </li>
+ </ul>
+ </td>
+ </tr>
+
+
</table>
<h2>logback-access</h2>
1
0

svn commit: r1425 - logback/trunk/logback-site/src/site/pages/manual
by noreply.seb@qos.ch 14 Mar '07
by noreply.seb@qos.ch 14 Mar '07
14 Mar '07
Author: seb
Date: Wed Mar 14 20:42:15 2007
New Revision: 1425
Modified:
logback/trunk/logback-site/src/site/pages/manual/joran.html
Log:
corrected minor mistake
Modified: logback/trunk/logback-site/src/site/pages/manual/joran.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/manual/joran.html (original)
+++ logback/trunk/logback-site/src/site/pages/manual/joran.html Wed Mar 14 20:42:15 2007
@@ -772,8 +772,8 @@
is first searched in configuration file or linked properties file,
and if not found there, it is then searched in system properties.
The corresponding value replaces <em>${aKey}</em> sequence. For example,
-if <em>java.home</em> system property is set to <em>/home/xyz</em>,
-then every occurrence of the sequence <em>${java.home}</em> will be
+if <em>java.home.dir</em> system property is set to <em>/home/xyz</em>,
+then every occurrence of the sequence <em>${java.home.dir}</em> will be
interpreted as <em>/home/xyz</em>.
</p>
1
0

svn commit: r1424 - logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic
by noreply.seb@qos.ch 12 Mar '07
by noreply.seb@qos.ch 12 Mar '07
12 Mar '07
Author: seb
Date: Mon Mar 12 20:54:33 2007
New Revision: 1424
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
Log:
Optimized calls
Modified the test of returning TurboFilter decision
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java Mon Mar 12 20:54:33 2007
@@ -370,29 +370,29 @@
}
public void debug(String msg) {
- filterAndLog(null, Level.DEBUG, msg, null, null);
+ filterAndLog(FQCN, null, Level.DEBUG, msg, null, null);
}
public void debug(String format, Object arg) {
- filterAndLog(null, Level.DEBUG, format, arg, null);
+ filterAndLog(FQCN, null, Level.DEBUG, format, arg, null);
}
public void debug(String format, Object arg1, Object arg2) {
- filterAndLog(null, Level.DEBUG, format, arg1, arg2, null);
+ filterAndLog(FQCN, null, Level.DEBUG, format, arg1, arg2, null);
}
public void debug(String format, Object[] argArray) {
- filterAndLog(null, Level.DEBUG, format, argArray, null);
+ filterAndLog(FQCN, null, Level.DEBUG, format, argArray, null);
}
public void debug(String msg, Throwable t) {
if (isDebugEnabled()) {
- filterAndLog(null, Level.DEBUG, msg, null, t);
+ filterAndLog(FQCN, null, Level.DEBUG, msg, null, t);
}
}
public final void debug(Marker marker, String msg) {
- filterAndLog(marker, Level.DEBUG, msg, null, null);
+ filterAndLog(FQCN, marker, Level.DEBUG, msg, null, null);
}
/**
@@ -406,7 +406,7 @@
final FilterReply decision = loggerContext.getTurboFilterChainDecision(
marker, this, Level.DEBUG, msg, param, t);
-
+
if (decision == FilterReply.NEUTRAL) {
if (effectiveLevelInt > level.levelInt) {
return;
@@ -465,125 +465,118 @@
}
final void filterAndLog(final Marker marker, final Level level,
- final String msg, final Object param1, final Throwable t) {
- filterAndLog(FQCN, marker, level, msg, param1, t);
- }
-
- final void filterAndLog(final Marker marker, final Level level,
final String msg, final Object param1, final Object param2,
final Throwable t) {
filterAndLog(FQCN, marker, level, msg, param1, param2, t);
}
- final void filterAndLog(final Marker marker, final Level level,
- final String msg, final Object[] params, final Throwable t) {
- filterAndLog(FQCN, marker, level, msg, params, t);
- }
-
public void debug(Marker marker, String format, Object arg) {
- filterAndLog(marker, Level.DEBUG, format, new Object[] { arg }, null);
+ filterAndLog(FQCN, marker, Level.DEBUG, format, arg, null);
}
public void debug(Marker marker, String format, Object arg1, Object arg2) {
- filterAndLog(marker, Level.DEBUG, format, new Object[] { arg1, arg2 }, null);
+ filterAndLog(FQCN, marker, Level.DEBUG, format, arg1, arg2 , null);
}
public void debug(Marker marker, String format, Object[] argArray) {
- filterAndLog(marker, Level.DEBUG, format, argArray, null);
+ filterAndLog(FQCN, marker, Level.DEBUG, format, argArray, null);
}
public void debug(Marker marker, String msg, Throwable t) {
- filterAndLog(marker, Level.DEBUG, msg, null, t);
+ filterAndLog(FQCN, marker, Level.DEBUG, msg, null, t);
}
public void error(String msg) {
- filterAndLog(null, Level.ERROR, msg, null, null);
+ filterAndLog(FQCN, null, Level.ERROR, msg, null, null);
}
public void error(String format, Object arg) {
- filterAndLog(null, Level.ERROR, format, new Object[] { arg }, null);
+ filterAndLog(FQCN, null, Level.ERROR, format, arg, null);
}
public void error(String format, Object arg1, Object arg2) {
- filterAndLog(null, Level.ERROR, format, new Object[] { arg1, arg2 }, null);
+ filterAndLog(FQCN, null, Level.ERROR, format, arg1, arg2, null);
}
public void error(String format, Object[] argArray) {
- filterAndLog(null, Level.ERROR, format, argArray, null);
+ filterAndLog(FQCN, null, Level.ERROR, format, argArray, null);
}
public void error(String msg, Throwable t) {
- filterAndLog(null, Level.ERROR, msg, null, t);
+ filterAndLog(FQCN, null, Level.ERROR, msg, null, t);
}
public void error(Marker marker, String msg) {
- filterAndLog(marker, Level.ERROR, msg, null, null);
+ filterAndLog(FQCN, marker, Level.ERROR, msg, null, null);
}
public void error(Marker marker, String format, Object arg) {
- filterAndLog(marker, Level.ERROR, format, new Object[] { arg }, null);
+ filterAndLog(FQCN, marker, Level.ERROR, format, arg, null);
}
public void error(Marker marker, String format, Object arg1, Object arg2) {
- filterAndLog(marker, Level.ERROR, format, new Object[] { arg1, arg2 }, null);
+ filterAndLog(FQCN, marker, Level.ERROR, format, arg1, arg2, null);
}
public void error(Marker marker, String format, Object[] argArray) {
- filterAndLog(marker, Level.ERROR, format, argArray, null);
+ filterAndLog(FQCN, marker, Level.ERROR, format, argArray, null);
}
public void error(Marker marker, String msg, Throwable t) {
- filterAndLog(marker, Level.ERROR, msg, null, t);
+ filterAndLog(FQCN, marker, Level.ERROR, msg, null, t);
}
public void info(String msg) {
- filterAndLog(null, Level.INFO, msg, null, null);
+ filterAndLog(FQCN, null, Level.INFO, msg, null, null);
}
public void info(String format, Object arg) {
- filterAndLog(null, Level.INFO, format, new Object[] { arg }, null);
+ filterAndLog(FQCN, null, Level.INFO, format, arg, null);
}
public void info(String format, Object arg1, Object arg2) {
- filterAndLog(null, Level.INFO, format, new Object[] { arg1, arg2 }, null);
+ filterAndLog(FQCN, null, Level.INFO, format, arg1, arg2, null);
}
public void info(String format, Object[] argArray) {
- filterAndLog(null, Level.INFO, format, argArray, null);
+ filterAndLog(FQCN, null, Level.INFO, format, argArray, null);
}
public void info(String msg, Throwable t) {
- filterAndLog(null, Level.INFO, msg, null, t);
+ filterAndLog(FQCN, null, Level.INFO, msg, null, t);
}
public void info(Marker marker, String msg) {
- filterAndLog(marker, Level.INFO, msg, null, null);
+ filterAndLog(FQCN, marker, Level.INFO, msg, null, null);
}
public void info(Marker marker, String format, Object arg) {
- filterAndLog(marker, Level.INFO, format, new Object[] { arg }, null);
+ filterAndLog(FQCN, marker, Level.INFO, format, arg , null);
}
public void info(Marker marker, String format, Object arg1, Object arg2) {
- filterAndLog(marker, Level.INFO, format, new Object[] { arg1, arg2 }, null);
+ filterAndLog(FQCN, marker, Level.INFO, format, arg1, arg2, null);
}
public void info(Marker marker, String format, Object[] argArray) {
- filterAndLog(marker, Level.INFO, format, argArray, null);
+ filterAndLog(FQCN, marker, Level.INFO, format, argArray, null);
}
public void info(Marker marker, String msg, Throwable t) {
- filterAndLog(marker, Level.INFO, msg, null, t);
+ filterAndLog(FQCN, marker, Level.INFO, msg, null, t);
}
public final boolean isDebugEnabled() {
- FilterReply decision = callTurboFilters(Level.DEBUG);
- if (decision.equals(FilterReply.ACCEPT)) {
- return true;
- } else if (decision.equals(FilterReply.DENY)) {
+ final FilterReply decision = callTurboFilters(Level.DEBUG);
+ if (decision == FilterReply.NEUTRAL) {
+ return effectiveLevelInt <= Level.DEBUG_INT;
+ } else if (decision == FilterReply.DENY) {
return false;
+ } else if (decision == FilterReply.ACCEPT){
+ return true;
+ } else {
+ throw new IllegalStateException("Unknown FilterReply value: " + decision);
}
- return (effectiveLevelInt <= Level.DEBUG_INT);
}
public boolean isDebugEnabled(Marker marker) {
@@ -592,12 +585,15 @@
public final boolean isErrorEnabled() {
FilterReply decision = callTurboFilters(Level.ERROR);
- if (decision.equals(FilterReply.ACCEPT)) {
- return true;
- } else if (decision.equals(FilterReply.DENY)) {
+ if (decision == FilterReply.NEUTRAL) {
+ return effectiveLevelInt <= Level.DEBUG_INT;
+ } else if (decision == FilterReply.DENY) {
return false;
+ } else if (decision == FilterReply.ACCEPT){
+ return true;
+ } else {
+ throw new IllegalStateException("Unknown FilterReply value: " + decision);
}
- return (effectiveLevelInt <= Level.ERROR_INT);
}
public boolean isErrorEnabled(Marker marker) {
@@ -606,12 +602,15 @@
public boolean isInfoEnabled() {
FilterReply decision = callTurboFilters(Level.INFO);
- if (decision.equals(FilterReply.ACCEPT)) {
- return true;
- } else if (decision.equals(FilterReply.DENY)) {
+ if (decision == FilterReply.NEUTRAL) {
+ return effectiveLevelInt <= Level.DEBUG_INT;
+ } else if (decision == FilterReply.DENY) {
return false;
+ } else if (decision == FilterReply.ACCEPT){
+ return true;
+ } else {
+ throw new IllegalStateException("Unknown FilterReply value: " + decision);
}
- return (effectiveLevelInt <= Level.INFO_INT);
}
public boolean isInfoEnabled(Marker marker) {
@@ -620,12 +619,15 @@
public boolean isWarnEnabled() {
FilterReply decision = callTurboFilters(Level.WARN);
- if (decision.equals(FilterReply.ACCEPT)) {
- return true;
- } else if (decision.equals(FilterReply.DENY)) {
+ if (decision == FilterReply.NEUTRAL) {
+ return effectiveLevelInt <= Level.DEBUG_INT;
+ } else if (decision == FilterReply.DENY) {
return false;
+ } else if (decision == FilterReply.ACCEPT){
+ return true;
+ } else {
+ throw new IllegalStateException("Unknown FilterReply value: " + decision);
}
- return (effectiveLevelInt <= Level.WARN_INT);
}
public boolean isWarnEnabled(Marker marker) {
@@ -634,52 +636,55 @@
public boolean isEnabledFor(Level level) {
FilterReply decision = callTurboFilters(level);
- if (decision.equals(FilterReply.ACCEPT)) {
- return true;
- } else if (decision.equals(FilterReply.DENY)) {
+ if (decision == FilterReply.NEUTRAL) {
+ return effectiveLevelInt <= Level.DEBUG_INT;
+ } else if (decision == FilterReply.DENY) {
return false;
+ } else if (decision == FilterReply.ACCEPT){
+ return true;
+ } else {
+ throw new IllegalStateException("Unknown FilterReply value: " + decision);
}
- return (effectiveLevelInt <= level.levelInt);
}
public void warn(String msg) {
- filterAndLog(null, Level.WARN, msg, null, null);
+ filterAndLog(FQCN, null, Level.WARN, msg, null, null);
}
public void warn(String msg, Throwable t) {
- filterAndLog(null, Level.WARN, msg, null, t);
+ filterAndLog(FQCN, null, Level.WARN, msg, null, t);
}
public void warn(String format, Object arg) {
- filterAndLog(null, Level.WARN, format, new Object[] { arg }, null);
+ filterAndLog(FQCN, null, Level.WARN, format, arg, null);
}
public void warn(String format, Object arg1, Object arg2) {
- filterAndLog(null, Level.WARN, format, new Object[] { arg1, arg2 }, null);
+ filterAndLog(FQCN, null, Level.WARN, format, arg1, arg2, null);
}
public void warn(String format, Object[] argArray) {
- filterAndLog(null, Level.WARN, format, argArray, null);
+ filterAndLog(FQCN, null, Level.WARN, format, argArray, null);
}
public void warn(Marker marker, String msg) {
- filterAndLog(marker, Level.WARN, msg, null, null);
+ filterAndLog(FQCN, marker, Level.WARN, msg, null, null);
}
public void warn(Marker marker, String format, Object arg) {
- filterAndLog(marker, Level.WARN, format, new Object[] { arg }, null);
+ filterAndLog(FQCN, marker, Level.WARN, format, arg, null);
}
public void warn(Marker marker, String format, Object[] argArray) {
- filterAndLog(marker, Level.WARN, format, argArray, null);
+ filterAndLog(FQCN, marker, Level.WARN, format, argArray, null);
}
public void warn(Marker marker, String format, Object arg1, Object arg2) {
- filterAndLog(marker, Level.WARN, format, new Object[] { arg1, arg2 }, null);
+ filterAndLog(FQCN, marker, Level.WARN, format, arg1, arg2, null);
}
public void warn(Marker marker, String msg, Throwable t) {
- filterAndLog(marker, Level.WARN, msg, null, t);
+ filterAndLog(FQCN, marker, Level.WARN, msg, null, t);
}
public boolean isAdditive() {
1
0

svn commit: r1423 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic test/java/ch/qos/logback/classic
by noreply.seb@qos.ch 12 Mar '07
by noreply.seb@qos.ch 12 Mar '07
12 Mar '07
Author: seb
Date: Mon Mar 12 17:38:55 2007
New Revision: 1423
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java
Log:
Added a test case
Fixed a bug
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java Mon Mar 12 17:38:55 2007
@@ -636,6 +636,8 @@
FilterReply decision = callTurboFilters(level);
if (decision.equals(FilterReply.ACCEPT)) {
return true;
+ } else if (decision.equals(FilterReply.DENY)) {
+ return false;
}
return (effectiveLevelInt <= level.levelInt);
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java Mon Mar 12 17:38:55 2007
@@ -67,6 +67,12 @@
assertTrue(logger.isEnabledFor(Level.INFO));
}
+ public void testIsEnabledForWithNoFilter() {
+ addNoFilter();
+ logger.setLevel(Level.DEBUG);
+ assertFalse(logger.isEnabledFor(Level.INFO));
+ }
+
public void testIsDebugEnabledWithNoFilter() {
addNoFilter();
logger.setLevel(Level.DEBUG);
1
0