[logback-dev] svn commit: r1178 - in logback/trunk: logback-access logback-examples/src/main/java/chapter5 logback-site/src/site/xdocTemplates/manual
noreply.seb at qos.ch
noreply.seb at qos.ch
Tue Jan 9 11:58:50 CET 2007
Author: seb
Date: Tue Jan 9 11:58:49 2007
New Revision: 1178
Modified:
logback/trunk/logback-access/pom.xml
logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java
logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java
logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml
Log:
Modified an MySampleLayout and MySampleLayout2 to use generics
Updated access' pom.xml with dependency to javax.mail
Modified: logback/trunk/logback-access/pom.xml
==============================================================================
--- logback/trunk/logback-access/pom.xml (original)
+++ logback/trunk/logback-access/pom.xml Tue Jan 9 11:58:49 2007
@@ -73,6 +73,13 @@
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
<build>
Modified: logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java
==============================================================================
--- logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java (original)
+++ logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java Tue Jan 9 11:58:49 2007
@@ -4,7 +4,7 @@
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.LayoutBase;
-public class MySampleLayout extends LayoutBase implements ClassicLayout {
+public class MySampleLayout extends LayoutBase<LoggingEvent> implements ClassicLayout {
public String doLayout(LoggingEvent event) {
StringBuffer sbuf = new StringBuffer(128);
@@ -20,8 +20,4 @@
sbuf.append(LINE_SEP);
return sbuf.toString();
}
-
- public String doLayout(Object event) {
- return doLayout((LoggingEvent)event);
- }
}
\ No newline at end of file
Modified: logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java
==============================================================================
--- logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java (original)
+++ logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java Tue Jan 9 11:58:49 2007
@@ -4,7 +4,7 @@
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.LayoutBase;
-public class MySampleLayout2 extends LayoutBase implements ClassicLayout {
+public class MySampleLayout2 extends LayoutBase<LoggingEvent> implements ClassicLayout {
String prefix = null;
boolean printThreadName = true;
@@ -38,8 +38,4 @@
sbuf.append(LINE_SEP);
return sbuf.toString();
}
-
- public String doLayout(Object event) {
- return doLayout((LoggingEvent) event);
- }
}
\ No newline at end of file
Modified: logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml Tue Jan 9 11:58:49 2007
@@ -118,7 +118,7 @@
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.LayoutBase;
-public class MySampleLayout extends LayoutBase implements ClassicLayout {
+public class MySampleLayout extends LayoutBase<LoggingEvent> implements ClassicLayout {
public String doLayout(LoggingEvent event) {
StringBuffer sbuf = new StringBuffer(128);
@@ -134,10 +134,6 @@
sbuf.append(LINE_SEP);
return sbuf.toString();
}
- //method declared in ch.qos.logback.core.Layout interface
- public String doLayout(Object event) {
- return doLayout((LoggingEvent)event);
- }
}</pre></div>
<p>
@@ -148,15 +144,14 @@
such as started or stopped status, header, footer and
content type access or logging context awareness. It allows
the developer to concentrate on the formatting she expects
- from her <code>Layout</code>.
+ from her <code>Layout</code>. Note that the <code>LayoutBase</code>
+ class is generic. By extending it, we precise the type that it will
+ have to handle, by adding <em><LoggingEvent></em> after its declaration.
</p>
<p><code>MySampleLayout</code> implements the <code>ClassicLayout</code>
interface, since it is intented to be used with the classic module.
- Therefore, it offers a trivial implementation of the
- <code>doLayout(Object event)</code> method, that only casts the event
- to the right type and passes it to the method where the actual formatting
- takes place.</p>
+ </p>
<p>The marginally more interesting <code>doLayout(LoggingEvent event)</code>
method begins by instantiating a StringBuffer. It proceeds by adding various
@@ -203,10 +198,10 @@
See <em>src/main/java/chapter5/SampleLogging.java</em> for precise details.</p>
<p>
- To run this example, as well as others in this
- chapter, please run the script provided in the <em>logback-examples</em> directory.
- Executing the command <em>java chapter5.SampleLogging src/main/java/chapter5/sampleLayoutConfig.xml</em>
- once in the <em>logback-examples</em> directory will produce the following output:
+ To run this example execute the command
+ <em>java chapter5.SampleLogging src/main/java/chapter5/sampleLayoutConfig.xml</em>
+ once in the <em>logback-examples</em> directory. This will produce the following
+ output:
</p>
<div class="source"><pre>0 DEBUG [main] chapter5.SampleLogging - Everything's going well
@@ -235,7 +230,7 @@
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.LayoutBase;
-public class MySampleLayout2 extends LayoutBase implements ClassicLayout {
+public class MySampleLayout2 extends LayoutBase<LoggingEvent> implements ClassicLayout {
String prefix = null;
boolean printThreadName = true;
@@ -269,10 +264,6 @@
sbuf.append(LINE_SEP);
return sbuf.toString();
}
-
- public String doLayout(Object event) {
- return doLayout((LoggingEvent) event);
- }
}</pre></div>
<p>Appart from the actual use of the two attributes, in the <code>doLayout</code> method,
More information about the logback-dev
mailing list