cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hudson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COCOON3-121) Create a generic generator that creates a root elemement and wraps the destination stream into it
Date Wed, 20 Feb 2013 22:19:21 GMT

    [ https://issues.apache.org/jira/browse/COCOON3-121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13582588#comment-13582588
] 

Hudson commented on COCOON3-121:
--------------------------------

Integrated in Cocoon 3.0 #237 (See [https://builds.apache.org/job/Cocoon%203.0/237/])
    COCOON3-121
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> (Revision 1448335)

     Result = SUCCESS
thorsten : http://svn.apache.org/viewvc/?view=rev&rev=1448335
Files : 
* /cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/generator
* /cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/generator/AddRootElementGenerator.java
* /cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/generator/package-info.java
* /cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-generators.xml

                
> 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

Mime
View raw message