[ 
https://issues.apache.org/jira/browse/COCOON3-121?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thorsten Scherler closed COCOON3-121.
-------------------------------------

    Resolution: Fixed

Committed revision 1448335.

                
> Create a generic generator that creates a root elemement and wraps the 
> destination stream into it
> -------------------------------------------------------------------------------------------------
>
>                 Key: COCOON3-121
>                 URL: https://issues.apache.org/jira/browse/COCOON3-121
>             Project: Cocoon 3
>          Issue Type: Bug
>          Components: cocoon-optional
>    Affects Versions: 3.0.0-beta-1
>            Reporter: Thorsten Scherler
>            Assignee: Thorsten Scherler
>             Fix For: 3.0.0-beta-1
>
>
> If you use something like ch.qos.logback.classic.log4j.XMLLayout you can 
> create xml based log files. However the problem is that it does not add root 
> element making the resulting file not well-formed. 
> You can activate the logging in your logback.xml like 
>    <appender name="FAILS" class="ch.qos.logback.core.FileAppender">
>         <file>${crawler.log.error}</file>
>         <append>false</append>
>         <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
>           <layout class="ch.qos.logback.classic.log4j.XMLLayout">
>             <locationInfo>true</locationInfo>
>           </layout>
>         </encoder>
>     </appender>
> The implemented solution has the following configuration in spring:
>   <bean name="generator:log4j" 
> class="org.apache.cocoon.optional.pipeline.components.sax.generator.AddRootElementGenerator"
>  scope="prototype">
>     <property name="encoding" value="UTF-8"/>
>     <property name="localName" value="events"/>
>     <property name="prefix" value="log4j"/>
>     <property name="namespace" value="http://jakarta.apache.org/log4j/"/>
>   </bean>
> and later parse the file that the appender gives like:
> <map:pipeline>
>       <map:match pattern="errorLogs">
>         <map:generate src="${crawler.log.error}" type="log4j"/>
>         <map:serialize type="xml" />
>       </map:match>
>     </map:pipeline>
> which will result in something like:
> <?xml version="1.0" encoding="UTF-8"?>
> <log4j:events xmlns:log4j="http://jakarta.apache.org/log4j/";>
>   <log4j:event logger="org.apache.droids.exception.ExceptionHandler" 
> timestamp="1361325224196" level="ERROR" thread="main">
>    <log4j:message><![CDATA[org.apache.droids.core.DroidsException: 
> org.apache.droids.core.DroidsException: 
> org.apache.droids.core.DroidsException: 
> org.apache.http.client.HttpResponseException: Internal Server Error 
> http://localhost:8888/xxx/details/xxx]]>
>   </log4j:message>
>   <log4j:locationInfo class="org.apache.droids.exception.ExceptionHandler" 
> method="handleException" file="ExceptionHandler.java" line="23"/>
>  </log4j:event>
> </log4j:events>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to