You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Wojciech Gdela <el...@poczta.onet.pl> on 2005/10/11 11:56:56 UTC

Log4j - logging request uri

Hello,

I've switched logging in my cocoon 2.1.7 app to log4j with the help of 
org.apache.avalon.excalibur.logger.Log4JLoggerManager in web.xml.

I would like to put request uri in my PatternLayout, is there a way to 
do it?

Now I have pattern: %d{ISO8601} %p [%c] - %m%n

And I get in my logs:
2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - Not found

I would like something like:
2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - (/foo/bla) Not 
found

-- 
Best regards,
Wojciech Gdela.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Log4j - logging request uri

Posted by Wojciech Gdela <el...@poczta.onet.pl>.
Hello,

>>I've switched logging in my cocoon 2.1.7 app to log4j with the help of
>>org.apache.avalon.excalibur.logger.Log4JLoggerManager in web.xml.
>>
>>I would like to put request uri in my PatternLayout, is there a way to
>>do it?
>>
>>Now I have pattern: %d{ISO8601} %p [%c] - %m%n
>>
>>And I get in my logs:
>>2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - Not found
>>
>>I would like something like:
>>2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - (/foo/bla) Not
>>found
> 
> 
> Create a component that implements the o.a.c.RequestListener interface.
> In its methods you can set set/remove the log4j diagnostic context with
> req.getRequestURI().

Worked for me, thanks!

-- 
Pozdrawiam,
Wojciech Gdela.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: repeaters & alternate row colours

Posted by Jorg Heymans <jh...@domek.be>.
Gunter D'Hondt wrote:

> <wt:repeater-size id="options" />

are you still using woody ? If you are in a position to upgrade then the
jx form macros can help you out here.


Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Log4j - logging request uri

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Carsten Ziegeler wrote:
> Jorg Heymans schrieb:
> 
>>Carsten Ziegeler wrote:
>>
>>
>>
>>>Not sure... :) Can you please repost the question?
>>
>>
>>Can one implement an OpenSessionInView pattern using the RequestListener
>>interface ?
>>
> 
> In 2.2 we have the EnterSitemapListener and LeaveSitemapListener
> interfaces you can implement. YOu can tie the implementation to a
> sitemap. I think with these interfaces, it's possible to implement the
> pattern.
Rocks !. Another thing that can be taken off web.xml.

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Log4j - logging request uri

Posted by Carsten Ziegeler <cz...@apache.org>.
Jorg Heymans schrieb:
> Carsten Ziegeler wrote:
> 
> 
>>Not sure... :) Can you please repost the question?
> 
> 
> Can one implement an OpenSessionInView pattern using the RequestListener
> interface ?
> 
In 2.2 we have the EnterSitemapListener and LeaveSitemapListener
interfaces you can implement. YOu can tie the implementation to a
sitemap. I think with these interfaces, it's possible to implement the
pattern.

HTH
Carsten

Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Log4j - logging request uri

Posted by Jorg Heymans <jh...@domek.be>.
Carsten Ziegeler wrote:

> Not sure... :) Can you please repost the question?

Can one implement an OpenSessionInView pattern using the RequestListener
interface ?


Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: repeaters & alternate row colours

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 13 oct. 05, à 10:02, Gunter D'Hondt a écrit :

> as Jorg also mentoined; I'm still using 2.1.4 (and cannot upgrade that
> quickly) so as far as I know I can't use the jx macros in that version
> any other possibilities?

you can post-process your form with an XSLT transform, and inject 
attributes on even/odd rows:

<xsl:template match="tr[position() mod 2 != 0]">
   ...copy element and add required attributes
</xsl:template>

-Bertrand


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


[Solved] Re: repeaters & alternate row colours

Posted by Gunter D'Hondt <gu...@sofico.be>.
Yep, thanks for the xslt code snippet!
Only a few adjustments so that the tbody is not necessary and the rest of 
the html is copied again:

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="table/@alternate" />

 <xsl:template match="table[@alternate ='true']">
        <table>
                <xsl:copy-of select="@*"/>
                <xsl:apply-templates select="tr" mode="alternate"/>
        </table>
 </xsl:template>

 <xsl:template match="tr" mode="alternate">
                 <xsl:copy>
                                 <xsl:apply-templates select="@*" />
                                 <xsl:attribute name="class">
                                                 <xsl:choose>
                                                                 <xsl:when 
test="position() mod 2 = 1">
  <xsl:text>GridRowOdd</xsl:text>
 </xsl:when>
 <xsl:otherwise>
  <xsl:text>GridRowEven</xsl:text>
 </xsl:otherwise>
                                                 </xsl:choose>
                                 </xsl:attribute>
                                 <xsl:apply-templates select="node() | @*" 
/>
                 </xsl:copy>
 </xsl:template>

  <xsl:template match="@*|node()" priority="-1">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

Regards,
Gunter







Mark Lundquist <ml...@wrinkledog.com> 
13/10/2005 10:07
Please respond to
users@cocoon.apache.org


To
users@cocoon.apache.org
cc

Subject
FW_SPAM: Re: repeaters & alternate row colours







On Oct 13, 2005, at 1:02 AM, Gunter D'Hondt wrote:

> as Jorg also mentoined; I'm still using 2.1.4 (and cannot upgrade that
> quickly) so as far as I know I can't use the jx macros in that version
> any other possibilities?

Sure.  I use XSLT for this, that way I can get this effect for any 
table I want, not just repeaters.

E.g.,

<xsl:stylesheet version="1.0"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

         <xsl:template match="table/@alternate" />

         <xsl:template match="table[@alternate ='true']/tbody">
                 <tbody>
                         <xsl:apply-templates select="tr" 
mode="alternate"/>
                 </tbody>
         </xsl:template>

         <xsl:template match="tr" mode="alternate">
                 <xsl:copy>
                         <xsl:apply-templates select="@*" />
                         <xsl:attribute name="class">
                                 <xsl:choose>
                                         <xsl:when test="position() mod 
2 = 1">
                                                 <xsl:text>odd</xsl:text>
                                         </xsl:when>
                                         <xsl:otherwise>
 
<xsl:text>even</xsl:text>
                                         </xsl:otherwise>
                                 </xsl:choose>
                         </xsl:attribute>
                         <xsl:apply-templates select="node() | @*" />
                 </xsl:copy>
         </xsl:template>

</xsl:stylesheet>

HTH,
—ml—


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




Re: repeaters & alternate row colours

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Oct 13, 2005, at 1:02 AM, Gunter D'Hondt wrote:

> as Jorg also mentoined; I'm still using 2.1.4 (and cannot upgrade that
> quickly) so as far as I know I can't use the jx macros in that version
> any other possibilities?

Sure.  I use XSLT for this, that way I can get this effect for any 
table I want, not just repeaters.

E.g.,

<xsl:stylesheet version="1.0"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

         <xsl:template match="table/@alternate" />

         <xsl:template match="table[@alternate ='true']/tbody">
                 <tbody>
                         <xsl:apply-templates select="tr" 
mode="alternate"/>
                 </tbody>
         </xsl:template>

         <xsl:template match="tr" mode="alternate">
                 <xsl:copy>
                         <xsl:apply-templates select="@*" />
                         <xsl:attribute name="class">
                                 <xsl:choose>
                                         <xsl:when test="position() mod 
2 = 1">
                                                 <xsl:text>odd</xsl:text>
                                         </xsl:when>
                                         <xsl:otherwise>
                                                 
<xsl:text>even</xsl:text>
                                         </xsl:otherwise>
                                 </xsl:choose>
                         </xsl:attribute>
                         <xsl:apply-templates select="node() | @*" />
                 </xsl:copy>
         </xsl:template>

</xsl:stylesheet>

HTH,
—ml—


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: repeaters & alternate row colours

Posted by Gunter D'Hondt <gu...@sofico.be>.
as Jorg also mentoined; I'm still using 2.1.4 (and cannot upgrade that 
quickly) so as far as I know I can't use the jx macros in that version
any other possibilities?

thnx,
Gunter





Christoph Hermann <ch...@guschtel.de> 
13/10/2005 09:35
Please respond to
users@cocoon.apache.org


To
users@cocoon.apache.org
cc

Subject
Re: repeaters & alternate row colours






Gunter D'Hondt schrieb:

Hello,

> In my form template I'd like to have alternate colours on the repeater 
> rows so that the output is something like 
> <tr id="row1">...</tr>
> <tr id="row2">...</tr>
> <tr id="row1">...</tr>
> ...

Use the JX Macros to do this:
<jx:import
uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
...
<jx:choose>
                 <jx:when test="${repeaterLoop.index % 2 == 0}">
                                 <!-- i'm not sure about the %2 == 0 
Syntax, but it should get you
going -->
                                 ...
                 </jx:when>
                 <jx:otherwise>
                 </jx:otherwise>
</jx:choose>

HTH
Christoph

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: repeaters & alternate row colours

Posted by Christoph Hermann <ch...@guschtel.de>.
Gunter D'Hondt schrieb:

Hello,

> In my form template I'd like to have alternate colours on the repeater 
> rows so that the output is something like 
> <tr id="row1">...</tr>
> <tr id="row2">...</tr>
> <tr id="row1">...</tr>
> ...

Use the JX Macros to do this:
<jx:import
uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
...
<jx:choose>
	<jx:when test="${repeaterLoop.index % 2 == 0}">
		<!-- i'm not sure about the %2 == 0 Syntax, but it should get you
going -->
		...
	</jx:when>
	<jx:otherwise>
	</jx:otherwise>
</jx:choose>

HTH
Christoph

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


repeaters & alternate row colours

Posted by Gunter D'Hondt <gu...@sofico.be>.
In my form template I'd like to have alternate colours on the repeater 
rows so that the output is something like 
<tr id="row1">...</tr>
<tr id="row2">...</tr>
<tr id="row1">...</tr>
...

does anybody have an idea how I can do this? below the snippet of my form 
template


                                <wt:repeater-size id="options" />
                                <table>
                                        <wt:repeater-widget id="options">
                                                <tr>
                                                        <td><wt:widget 
id="description"/></td>
                                                </tr>
                                        </wt:repeater-widget>
                                </table>

is there a method of retrieving the repeater row-id?


thanks in advance,
Gunter


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Log4j - logging request uri

Posted by Carsten Ziegeler <cz...@apache.org>.
Jorg Heymans wrote:
> 
> Leszek Gawron wrote:
> 
>>That's useful! And should be wikified IMO :) Can I implement a
>>OpenSessionInView pattern with this?
>>
> 
> 
> I remember you asking this before on dev@, when Carsten announced this
> interface. I don't think he ever answered actually, ehrm Carsten ?
> 
Not sure... :) Can you please repost the question?


Carsten


-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Log4j - logging request uri

Posted by Jorg Heymans <jh...@domek.be>.

Leszek Gawron wrote:
> 
> That's useful! And should be wikified IMO :) Can I implement a
> OpenSessionInView pattern with this?
> 

I remember you asking this before on dev@, when Carsten announced this
interface. I don't think he ever answered actually, ehrm Carsten ?

Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Log4j - logging request uri

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Jorg Heymans wrote:
> Wojciech Gdela wrote:
> 
>>I've switched logging in my cocoon 2.1.7 app to log4j with the help of
>>org.apache.avalon.excalibur.logger.Log4JLoggerManager in web.xml.
>>
>>I would like to put request uri in my PatternLayout, is there a way to
>>do it?
>>
>>Now I have pattern: %d{ISO8601} %p [%c] - %m%n
>>
>>And I get in my logs:
>>2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - Not found
>>
>>I would like something like:
>>2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - (/foo/bla) Not
>>found
> 
> 
> Create a component that implements the o.a.c.RequestListener interface.
> In its methods you can set set/remove the log4j diagnostic context with
> req.getRequestURI().
That's useful! And should be wikified IMO :) Can I implement a 
OpenSessionInView pattern with this?

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Log4j - logging request uri

Posted by Jorg Heymans <jh...@domek.be>.
Wojciech Gdela wrote:
> 
> I've switched logging in my cocoon 2.1.7 app to log4j with the help of
> org.apache.avalon.excalibur.logger.Log4JLoggerManager in web.xml.
> 
> I would like to put request uri in my PatternLayout, is there a way to
> do it?
> 
> Now I have pattern: %d{ISO8601} %p [%c] - %m%n
> 
> And I get in my logs:
> 2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - Not found
> 
> I would like something like:
> 2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - (/foo/bla) Not
> found

Create a component that implements the o.a.c.RequestListener interface.
In its methods you can set set/remove the log4j diagnostic context with
req.getRequestURI().


HTH
Jorg



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Log4j - logging request uri

Posted by Leszek Gawron <lg...@mobilebox.pl>.
Wojciech Gdela wrote:
> Hello,
> 
> I've switched logging in my cocoon 2.1.7 app to log4j with the help of 
> org.apache.avalon.excalibur.logger.Log4JLoggerManager in web.xml.
> 
> I would like to put request uri in my PatternLayout, is there a way to 
> do it?
probably not - for LogKit there is a custom formatter implemented. I 
haven't seen similar formatter for log4j.

> 
> Now I have pattern: %d{ISO8601} %p [%c] - %m%n
> 
> And I get in my logs:
> 2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - Not found
> 
> I would like something like:
> 2005-10-11 11:46:26,227 ERROR [sitemap.handled-errors] - (/foo/bla) Not 
> found


-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org