You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Andres Almiray <aa...@yahoo.com> on 2006/06/12 04:34:43 UTC

Feature request: stack trace filtering

Hi,

When using Eclipse I discovered a feature that filters
out specific lines of a stack trace when running
tests. I thought that this was a log4j feature but
saddly it is not. 
I work with AOP and other technologies that produce a
*very long* stack trace with many plumbing code in
between and I would really want to see only the
"relevant" error lines from the logic.

I have already coded two appenders (Console and
RollingFile) that take care of filtering specific
lines (using the xml file format) and would like to
contribute them.

Configuration is as simple as:

<appender name="STDOUT"
class="org.kordamp.construct.commons.log.FilteringConsoleAppender">
   <param name="FilterPattern" value="sun.reflect.*"/>
   <param name="FilterPattern"
value="org.springframework.aop.support.*"/>
   <param name="FilterPattern"
value="org.springframework.aop.framework.*"/>
   <param name="FilterPattern" value=".Proxy.*"/>
   <param name="FilterPattern"
value="java.lang.reflect.Method.invoke.*"/>
   <param name="FilterPattern"
value="java.lang.Thread.run.*"/>
   <param name="FilterPattern"
value="java.security.AccessController.*"/>
   <param name="FilterPattern" value="org.mortbay.*"/>
   <param name="FilterPattern"
value="javax.servlet.http.*"/>
   <param name="FilterPattern"
value="junit.framework.*"/>
   <param name="Target" value="System.out" />
   <layout class="org.apache.log4j.PatternLayout">
   <param name="ConversionPattern"
      value="[%d{yyyy-MM-dd HH:mm:ss}] %-6p
[%-20.20c{1}:%4L] %m%n" />
   </layout>
</appender>

Regards.

-------------------------------------------
Ing. Andres Almiray Jaramillo
http://jroller.com/page/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and those who don't.
To understand recursion, we must first understand recursion.

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Feature request: stack trace filtering

Posted by Andres Almiray <aa...@yahoo.com>.
James,

I took I dive into the 1.3-alpha8 codebase, and found
that the more reusable solution would be to allow
ThrowableInformationPatternConverter to have a set of
patterns, in order to filter the stack trace lines.

Reading further into the code, I couldn't find an easy
way to set this patterns, as the patternConverters are
initialized by a helper class (PatterParser) and there
is no direct way for a property set on or referenced
by PatterLayout to be passed to any patternConverter.

Also, PatterLayout and
ThrowableInformationPatternConverter do not let
themselves to extension very well, as some of the
inner attributes are marked private without protected
accessors/modifiers and the activateOptions
initialization .

The solution I came up with is as following:
- in PatterLayout:
1. change to protected access patternConverters. This
will help the following changes.
2. change activateOptions() to a template method, this
aids subclasses and allows for a more fine grained
initialization.
3. register a set of converter only properties to
allow "property injection" to any registered
PatternConverter using reflection/property
descriptors.

- in ThrowableInformationPatternConverter
1. add a "String[] patterns" property with public
setter.
2. add a "boolean perl5" property with public setter.
This will help choose the pattern matcher strategy
(either JDK [when in 1.4+] or ORO [when in 1.3])
3. perform pattern strategy initialization when
patterns property is set.
4. modify format() to verify each stack trace line
against the set of patterns.
5. default configuration will be "match all lines".


 --- James Stauffer <st...@gmail.com>
escribió:

> Instead of writing new appenders it would probably
> be better to write
> a new layout.  Then it could be used with every
> appender.
> 
> On 6/11/06, Andres Almiray <aa...@yahoo.com>
> wrote:
> > Hi,
> >
> > When using Eclipse I discovered a feature that
> filters
> > out specific lines of a stack trace when running
> > tests. I thought that this was a log4j feature but
> > saddly it is not.
> > I work with AOP and other technologies that
> produce a
> > *very long* stack trace with many plumbing code in
> > between and I would really want to see only the
> > "relevant" error lines from the logic.
> >
> > I have already coded two appenders (Console and
> > RollingFile) that take care of filtering specific
> > lines (using the xml file format) and would like
> to
> > contribute them.
> >
> > Configuration is as simple as:
> >
> > <appender name="STDOUT"
> >
>
class="org.kordamp.construct.commons.log.FilteringConsoleAppender">
> >    <param name="FilterPattern"
> value="sun.reflect.*"/>
> >    <param name="FilterPattern"
> > value="org.springframework.aop.support.*"/>
> >    <param name="FilterPattern"
> > value="org.springframework.aop.framework.*"/>
> >    <param name="FilterPattern" value=".Proxy.*"/>
> >    <param name="FilterPattern"
> > value="java.lang.reflect.Method.invoke.*"/>
> >    <param name="FilterPattern"
> > value="java.lang.Thread.run.*"/>
> >    <param name="FilterPattern"
> > value="java.security.AccessController.*"/>
> >    <param name="FilterPattern"
> value="org.mortbay.*"/>
> >    <param name="FilterPattern"
> > value="javax.servlet.http.*"/>
> >    <param name="FilterPattern"
> > value="junit.framework.*"/>
> >    <param name="Target" value="System.out" />
> >    <layout class="org.apache.log4j.PatternLayout">
> >    <param name="ConversionPattern"
> >       value="[%d{yyyy-MM-dd HH:mm:ss}] %-6p
> > [%-20.20c{1}:%4L] %m%n" />
> >    </layout>
> > </appender>
> >
> > Regards.
> >
> > -------------------------------------------
> > Ing. Andres Almiray Jaramillo
> > http://jroller.com/page/aalmiray
> > --
> > What goes up, must come down. Ask any system
> administrator.
> > There are 10 types of people in the world: Those
> who understand binary, and those who don't.
> > To understand recursion, we must first understand
> recursion.
> >
> > __________________________________________________
> > Correo Yahoo!
> > Espacio para todos tus mensajes, antivirus y
> antispam ¡gratis!
> > Regístrate ya - http://correo.yahoo.com.mx/
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> >
> >
> 
> 
> -- 
> James Stauffer
> Are you good? Take the test at
> http://www.livingwaters.com/good/
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
> 


-------------------------------------------
Ing. Andres Almiray Jaramillo
http://jroller.com/page/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and those who don't.
To understand recursion, we must first understand recursion.


	
	
		
___________________________________________________________ 
Do You Yahoo!? 
La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.com.mx 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Feature request: stack trace filtering

Posted by James Stauffer <st...@gmail.com>.
Instead of writing new appenders it would probably be better to write
a new layout.  Then it could be used with every appender.

On 6/11/06, Andres Almiray <aa...@yahoo.com> wrote:
> Hi,
>
> When using Eclipse I discovered a feature that filters
> out specific lines of a stack trace when running
> tests. I thought that this was a log4j feature but
> saddly it is not.
> I work with AOP and other technologies that produce a
> *very long* stack trace with many plumbing code in
> between and I would really want to see only the
> "relevant" error lines from the logic.
>
> I have already coded two appenders (Console and
> RollingFile) that take care of filtering specific
> lines (using the xml file format) and would like to
> contribute them.
>
> Configuration is as simple as:
>
> <appender name="STDOUT"
> class="org.kordamp.construct.commons.log.FilteringConsoleAppender">
>    <param name="FilterPattern" value="sun.reflect.*"/>
>    <param name="FilterPattern"
> value="org.springframework.aop.support.*"/>
>    <param name="FilterPattern"
> value="org.springframework.aop.framework.*"/>
>    <param name="FilterPattern" value=".Proxy.*"/>
>    <param name="FilterPattern"
> value="java.lang.reflect.Method.invoke.*"/>
>    <param name="FilterPattern"
> value="java.lang.Thread.run.*"/>
>    <param name="FilterPattern"
> value="java.security.AccessController.*"/>
>    <param name="FilterPattern" value="org.mortbay.*"/>
>    <param name="FilterPattern"
> value="javax.servlet.http.*"/>
>    <param name="FilterPattern"
> value="junit.framework.*"/>
>    <param name="Target" value="System.out" />
>    <layout class="org.apache.log4j.PatternLayout">
>    <param name="ConversionPattern"
>       value="[%d{yyyy-MM-dd HH:mm:ss}] %-6p
> [%-20.20c{1}:%4L] %m%n" />
>    </layout>
> </appender>
>
> Regards.
>
> -------------------------------------------
> Ing. Andres Almiray Jaramillo
> http://jroller.com/page/aalmiray
> --
> What goes up, must come down. Ask any system administrator.
> There are 10 types of people in the world: Those who understand binary, and those who don't.
> To understand recursion, we must first understand recursion.
>
> __________________________________________________
> Correo Yahoo!
> Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
> Regístrate ya - http://correo.yahoo.com.mx/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org