In TimestampInequalityRule and TimestampEqualityRule, we could support a 2nd simpledateformat transparently, which would kick in if the long format couldn't parse the argument.
The 2nd simpledateformat could be 'HH:mm:ss' - add the millis representing the current day at midnight to those millis and use that long in comparisons. The one drawback is you couldn't make inequality comparisons across midnight. Just a thought. I coded it up and it was pretty straightforward and worked well, but I'm not sure that's what we want to do. I'm also not sure how we would tackle LikeRule. Scott -----Original Message----- From: Curt Arnold [mailto:[EMAIL PROTECTED] Sent: Wed 8/15/2007 10:58 PM To: Log4J Users List Subject: Re: ExpressionFilter and TIMESPAN 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
