logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: ExpressionFilter and TIMESPAN
Date Thu, 16 Aug 2007 05:58:10 GMT

On Aug 15, 2007, at 11:03 AM, WALLIS, Simon, GBM wrote:

> Oops, I meant to type TIMESTAMP, not TIMESPAN.
> -----Original Message-----
> From: WALLIS, Simon, GBM
> Sent: 15 August 2007 16:58
> To: 'Log4J Users List'
> Subject: ExpressionFilter and TIMESPAN
> Hi again,
> I'm wondering if it is possible to use the ExpressionFilter to only  
> log
> events occurring within a certain time span each day. For example,  
> I don't
> want to log events in my application between the hours of 01:00 and  
> 03:00
> (due to scheduled environment outage where tons of errors are  
> spewed forth).
> It seems that the TIMESPAN filter field in ExpressionFilter is a  
> long which
> represents a specific date. So I could then log all events  
> occurring after,
> say, "2007/01/01 12:00". But can I use this to only log events  
> relative to a
> certain time each day? If it can only be a hard date, then I don't  
> see much
> point of the filter, unless you knew that you didn't want to log  
> information
> for a given day at some point in the future (an unlikely scenario).
> Here's my appender below. I've got it to only log events from  
> com.creditex,
> but I want to restrict it further that that it doesn't log events  
> between
> 01:00 and 03:00 each day.
> <appender name="ConsoleAppender"  
> class="org.apache.log4j.ConsoleAppender">
> 	<layout class="org.apache.log4j.PatternLayout">
> 		<param name="ConversionPattern" value="%d %-5p [%t] %c
> (%F:%L) - %m%n"/>
> 	</layout>
> 	<filter class="org.apache.log4j.filter.ExpressionFilter">
> 		<param name="Expression" value="(LOGGER ~= com.creditex)" />
> 		<param name="AcceptOnMatch" value="true"/>
> 		<param name="ConvertInFixToPostFix" value="true"/>
> 	</filter>
> 	<filter class="org.apache.log4j.filter.DenyAllFilter"/>
> </appender>
> One more thing: why is TIMESPAN a long instead of a date string in the
> format of, say, "yyyy/MM/dd hh:mm:ss". Is there a quick way to  
> determine the
> long value of a date I have in mind?
> Cheers.

I added a time field to XSLTLayout that contains the same info as  
timestamp, but in XML Schema's dateTime data type's lexical format  
(for example, 2007-08-16T06:46:56.124Z).  A similar "field" could be  
added to ExpressionFilter and you could get your 2 hour down time  
with an appropriate like expression.  You'd want to support all the  
equality and comparison operators in the value space and have the  
LIKE operator work in the XML schema lexical space.  Doesn't seem  
like a clean way without hacking LikeRule, EqualityRule and  
InequalityRule to add special cases.

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

View raw message