Index: cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
===================================================================
--- cocoon-sample/src/main/resources/COB-INF/sitemap.xmap	(revision 1072135)
+++ cocoon-sample/src/main/resources/COB-INF/sitemap.xmap	(working copy)
@@ -45,14 +45,8 @@
         <map:transform src="sax-pipeline/simple.xslt">
           <map:parameter name="myParam" value="1" />
         </map:transform>
-        <!--
-        <map:transform type="logasxml">
-          <map:parameter name="logfile" value="target/logasxml.log" />
-        </map:transform>
-        <map:transform type="log">
-          <map:parameter name="logfile" value="target/logsaxevents.log" />
-        </map:transform>
-        -->
+        <map:transform type="logasxml"/>
+        <map:transform type="log"/>
         <map:serialize />
       </map:match>
       <map:match equals="sax-pipeline/simple-1">
Index: cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LogTransformer.java
===================================================================
--- cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LogTransformer.java	(revision 1072135)
+++ cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LogTransformer.java	(working copy)
@@ -42,9 +42,11 @@
  */
 public final class LogTransformer extends AbstractSAXTransformer {
 
-    private static final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
+    private static final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat(
+            "yyyy-MM-dd'T'hh:mm:ss");
 
-    private static final String LINE_SEPARATOR = System.getProperty("line.separator", "\n");
+    private static final String LINE_SEPARATOR = System.getProperty(
+            "line.separator", "\n");
 
     private static final String LOG_FILE = "logfile";
 
@@ -75,15 +77,18 @@
         this.dateFormat = ISO_FORMAT;
     }
 
-    public LogTransformer(File logFile, boolean append) throws IOException {
+    public LogTransformer(File logFile, boolean append)
+            throws IOException {
         this(logFile, append, ISO_FORMAT);
     }
 
-    public LogTransformer(File logFile, boolean append, String datePattern) throws IOException {
+    public LogTransformer(File logFile, boolean append, String datePattern)
+            throws IOException {
         this(logFile, append, new SimpleDateFormat(datePattern));
     }
 
-    public LogTransformer(File logFile, boolean append, SimpleDateFormat dateFormat) throws IOException {
+    public LogTransformer(File logFile, boolean append, SimpleDateFormat dateFormat)
+            throws IOException {
         this.logWriter = new FileWriter(logFile, append);
         this.dateFormat = dateFormat;
     }
@@ -121,7 +126,8 @@
 
         Object datePatternString = parameters.get(DATE_PATTERN);
         if (datePatternString != null) {
-            this.dateFormat = new SimpleDateFormat(String.valueOf(datePatternString));
+            this.dateFormat = new SimpleDateFormat(String.valueOf(
+                    datePatternString));
         }
     }
 
@@ -129,7 +135,11 @@
     public void finish() {
         if (this.logWriter != null) {
             try {
-                this.logWriter.close();
+                if (System.out.equals(this.logWriter)) {
+                    this.logWriter.flush();
+                } else {
+                    this.logWriter.close();
+                }
             } catch (IOException e) {
                 this.log.debug("Impossible to close the log writer", e);
             }
@@ -144,25 +154,29 @@
     }
 
     @Override
-    public void comment(char[] ch, int start, int length) throws SAXException {
+    public void comment(char[] ch, int start, int length)
+            throws SAXException {
         this.log("comment", new String(ch, start, length));
         super.comment(ch, start, length);
     }
 
     @Override
-    public void endCDATA() throws SAXException {
+    public void endCDATA()
+            throws SAXException {
         this.log("endCDATA", null);
         super.endCDATA();
     }
 
     @Override
-    public void endDocument() throws SAXException {
+    public void endDocument()
+            throws SAXException {
         this.log("endDocument", null);
         super.endDocument();
     }
 
     @Override
-    public void endDTD() throws SAXException {
+    public void endDTD()
+            throws SAXException {
         this.log("endDTD", null);
         super.endDTD();
     }
@@ -180,19 +194,22 @@
     }
 
     @Override
-    public void endEntity(String name) throws SAXException {
+    public void endEntity(String name)
+            throws SAXException {
         this.log("endEntity", "name=" + name);
         super.endEntity(name);
     }
 
     @Override
-    public void endPrefixMapping(String prefix) throws SAXException {
+    public void endPrefixMapping(String prefix)
+            throws SAXException {
         this.log("endPrefixMapping", "prefix=" + prefix);
         super.endPrefixMapping(prefix);
     }
 
     @Override
-    public SAXBuffer endSAXRecording() throws SAXException {
+    public SAXBuffer endSAXRecording()
+            throws SAXException {
         this.log("endSAXRecording", null);
         return super.endSAXRecording();
     }
@@ -200,7 +217,7 @@
     @Override
     public void ignorableWhitespace(char[] ch, int start, int length)
             throws SAXException {
-        this.log("ignorableWhitespace", new String(ch,start,length));
+        this.log("ignorableWhitespace", new String(ch, start, length));
         super.ignorableWhitespace(ch, start, length);
     }
 
@@ -224,19 +241,22 @@
     }
 
     @Override
-    public void skippedEntity(String name) throws SAXException {
+    public void skippedEntity(String name)
+            throws SAXException {
         this.log("skippedEntity", "name=" + name);
         super.skippedEntity(name);
     }
 
     @Override
-    public void startCDATA() throws SAXException {
+    public void startCDATA()
+            throws SAXException {
         this.log("startCDATA", null);
         super.startCDATA();
     }
 
     @Override
-    public void startDocument() throws SAXException {
+    public void startDocument()
+            throws SAXException {
         this.log("startDocument", null);
         super.startDocument();
     }
@@ -255,7 +275,8 @@
 
     @Override
     public void startElement(String uri, String localName, String name,
-            Attributes atts) throws SAXException {
+            Attributes atts)
+            throws SAXException {
         this.log("startElement", "uri="
                 + uri
                 + ", localName="
@@ -264,23 +285,24 @@
                 + name);
         for (int i = 0; i < atts.getLength(); i++) {
             this.log("            ", (i + 1)
-                 + ". uri="
-                 + atts.getURI(i)
-                 + ", local="
-                 + atts.getLocalName(i)
-                 + ", qname="
-                 + atts.getQName(i)
-                 + ", type="
-                 + atts.getType(i)
-                 + ", value="
-                 + atts.getValue(i));
+                    + ". uri="
+                    + atts.getURI(i)
+                    + ", local="
+                    + atts.getLocalName(i)
+                    + ", qname="
+                    + atts.getQName(i)
+                    + ", type="
+                    + atts.getType(i)
+                    + ", value="
+                    + atts.getValue(i));
         }
         super.startElement(uri, localName, name, atts);
     }
 
     @Override
-    public void startEntity(String name) throws SAXException {
-        this.log ("startEntity", "name=" + name);
+    public void startEntity(String name)
+            throws SAXException {
+        this.log("startEntity", "name=" + name);
         super.startEntity(name);
     }
 
@@ -295,8 +317,9 @@
     }
 
     @Override
-    public void startSAXRecording() throws SAXException {
-        this.log ("startSAXRecording", null);
+    public void startSAXRecording()
+            throws SAXException {
+        this.log("startSAXRecording", null);
         super.startSAXRecording();
     }
 
Index: cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LogAsXMLTransformer.java
===================================================================
--- cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LogAsXMLTransformer.java	(revision 1072135)
+++ cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LogAsXMLTransformer.java	(working copy)
@@ -50,8 +50,9 @@
      */
     private static final Log LOG = LogFactory.getLog(LogAsXMLTransformer.class);
 
-    private final XMLSerializer xmlSerializer = XMLSerializer.createXMLSerializer();
-    
+    private final XMLSerializer xmlSerializer = XMLSerializer.
+            createXMLSerializer();
+
     private OutputStream outputStream;
 
     public LogAsXMLTransformer() {
@@ -110,7 +111,11 @@
         this.xmlSerializer.finish();
         if (this.outputStream != null) {
             try {
-                this.outputStream.close();
+                if (System.out.equals(this.outputStream)) {
+                    this.outputStream.flush();
+                } else {
+                    this.outputStream.close();
+                }
             } catch (IOException e) {
                 LOG.debug("Impossible to close the log writer", e);
             }
@@ -125,25 +130,29 @@
     }
 
     @Override
-    public void comment(char[] ch, int start, int length) throws SAXException {
+    public void comment(char[] ch, int start, int length)
+            throws SAXException {
         this.xmlSerializer.comment(ch, start, length);
         super.comment(ch, start, length);
     }
 
     @Override
-    public void endCDATA() throws SAXException {
+    public void endCDATA()
+            throws SAXException {
         this.xmlSerializer.endCDATA();
         super.endCDATA();
     }
 
     @Override
-    public void endDocument() throws SAXException {
+    public void endDocument()
+            throws SAXException {
         this.xmlSerializer.endDocument();
         super.endDocument();
     }
 
     @Override
-    public void endDTD() throws SAXException {
+    public void endDTD()
+            throws SAXException {
         this.xmlSerializer.endDTD();
         super.endDTD();
     }
@@ -156,13 +165,15 @@
     }
 
     @Override
-    public void endEntity(String name) throws SAXException {
+    public void endEntity(String name)
+            throws SAXException {
         this.xmlSerializer.endEntity(name);
         super.endEntity(name);
     }
 
     @Override
-    public void endPrefixMapping(String prefix) throws SAXException {
+    public void endPrefixMapping(String prefix)
+            throws SAXException {
         this.xmlSerializer.endPrefixMapping(prefix);
         super.endPrefixMapping(prefix);
     }
@@ -188,19 +199,22 @@
     }
 
     @Override
-    public void skippedEntity(String name) throws SAXException {
+    public void skippedEntity(String name)
+            throws SAXException {
         this.xmlSerializer.skippedEntity(name);
         super.skippedEntity(name);
     }
 
     @Override
-    public void startCDATA() throws SAXException {
+    public void startCDATA()
+            throws SAXException {
         this.xmlSerializer.startCDATA();
         super.startCDATA();
     }
 
     @Override
-    public void startDocument() throws SAXException {
+    public void startDocument()
+            throws SAXException {
         this.xmlSerializer.startDocument();
         super.startDocument();
     }
@@ -214,13 +228,15 @@
 
     @Override
     public void startElement(String uri, String localName, String name,
-            Attributes atts) throws SAXException {
+            Attributes atts)
+            throws SAXException {
         this.xmlSerializer.startElement(uri, localName, name, atts);
         super.startElement(uri, localName, name, atts);
     }
 
     @Override
-    public void startEntity(String name) throws SAXException {
+    public void startEntity(String name)
+            throws SAXException {
         this.xmlSerializer.startEntity(name);
         super.startEntity(name);
     }
