You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Brian Carlson <bc...@Tier.com> on 2010/04/19 23:07:38 UTC

Filters with AND/OR conditions.

I have 2 properties that I need to filter log messages based upon.  I
have setup an smtp appender for Error and Fatal log messages, but a
couple components didn't implement logging properly and are logging
errors when they don't exist.  That problem is being dealt with.  So I'm
trying to take care of those messages with filters.  What is the best
way to setup something like this:

 

If (Property1 = "111" && Property2 = "abc" )  || 

    (Property1 = "111" && Property2 = "bbb") ||

    (Property1 = "222" && Property2 = "def") ||

    (Property1 = "333" && Property2 = "xyz"))

Then

                Deny

Else

                Accept

 

 

Any help would be great.

 

Thanks,

Brian


Re: Filters with AND/OR conditions.

Posted by Ron Grabowski <ro...@yahoo.com>.
If you can deploy your own assembly to the server that contains your custom filter that'll make your life a lot easier. I don't think what you want is possible using just the built-in filters.



________________________________
From: Brian Carlson <bc...@Tier.com>
To: Log4NET User <lo...@logging.apache.org>
Sent: Tue, April 20, 2010 1:21:44 AM
Subject: RE: Filters with AND/OR conditions.

  
Ron,
 
It’s
likely going to need to be dynamic.   Since once we turn on smtp notification,
there might be other offenders that are identified and will need to be added.
 
Brian
 
From:Ron Grabowski
[mailto:rongrabowski@yahoo.com] 
Sent: Monday, April 19, 2010 10:55 PM
To: Log4NET User
Subject: Re: Filters with AND/OR conditions.
 
Can you deploy assemblies to the server and just hard-code
your logic check using C#:

public class MyFilter : FilterSkeleton
{
    public override FilterDecision Decide(LoggingEvent
loggingEvent)
    {
        /*
        If (Property1 = “111” &&
Property2 = “abc” ) ||
            (Property1 =
”111” && Property2 = “bbb”) ||
            (Property1 =
”222” && Property2 = “def”) ||
            (Property1 =
”333” && Property2 = “xyz”))
        Then
            Deny
        Else
            Accept
        */
    }
}

or must it by dynamic?
 

________________________________
 
From:Brian Carlson
<bc...@Tier.com>
To: log4net-user@logging.apache.org
Sent: Mon, April 19, 2010 5:07:38 PM
Subject: Filters with AND/OR conditions.



I have 2 properties that I need to filter log messages based
upon.  I have setup an smtp appender for Error and Fatal log messages, but
a couple components didn’t implement logging properly and are logging errors
when they don’t exist.  That problem is being dealt with.  So I’m trying
to take care of those messages with filters.  What is the best way to
setup something like this:
 
If (Property1 = “111” && Property2 = “abc” ) 
|| 
    (Property1 = ”111” && Property2 =
“bbb”) ||
    (Property1 = ”222” && Property2 =
“def”) ||
    (Property1 = ”333” && Property2 =
“xyz”))
Then
               
Deny
Else
               
Accept
 
 
Any help would be great.
 
Thanks,
Brian

RE: Filters with AND/OR conditions.

Posted by Brian Carlson <bc...@Tier.com>.
Ron,

 

It’s likely going to need to be dynamic.   Since once we turn on smtp notification, there might be other offenders that are identified and will need to be added.

 

Brian

 

From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Monday, April 19, 2010 10:55 PM
To: Log4NET User
Subject: Re: Filters with AND/OR conditions.

 

Can you deploy assemblies to the server and just hard-code your logic check using C#:

public class MyFilter : FilterSkeleton
{
    public override FilterDecision Decide(LoggingEvent loggingEvent)
    {
        /*
        If (Property1 = “111” && Property2 = “abc” ) ||
            (Property1 = ”111” && Property2 = “bbb”) ||
            (Property1 = ”222” && Property2 = “def”) ||
            (Property1 = ”333” && Property2 = “xyz”))
        Then
            Deny
        Else
            Accept
        */
    }
}

or must it by dynamic?

 

________________________________

From: Brian Carlson <bc...@Tier.com>
To: log4net-user@logging.apache.org
Sent: Mon, April 19, 2010 5:07:38 PM
Subject: Filters with AND/OR conditions.




I have 2 properties that I need to filter log messages based upon.  I have setup an smtp appender for Error and Fatal log messages, but a couple components didn’t implement logging properly and are logging errors when they don’t exist.  That problem is being dealt with.  So I’m trying to take care of those messages with filters.  What is the best way to setup something like this:

 

If (Property1 = “111” && Property2 = “abc” )  || 

    (Property1 = ”111” && Property2 = “bbb”) ||

    (Property1 = ”222” && Property2 = “def”) ||

    (Property1 = ”333” && Property2 = “xyz”))

Then

                Deny

Else

                Accept

 

 

Any help would be great.

 

Thanks,

Brian


Re: Filters with AND/OR conditions.

Posted by Ron Grabowski <ro...@yahoo.com>.
Can you deploy assemblies to the server and just hard-code your logic check using C#:

public class MyFilter : FilterSkeleton
{
    public override FilterDecision Decide(LoggingEvent loggingEvent)
    {
        /*
        If (Property1 = “111” && Property2 = “abc” ) ||
            (Property1 = ”111” && Property2 = “bbb”) ||
            (Property1 = ”222” && Property2 = “def”) ||
            (Property1 = ”333” && Property2 = “xyz”))
        Then
            Deny
        Else
            Accept
        */
    }
}

or must it by dynamic?




________________________________
From: Brian Carlson <bc...@Tier.com>
To: log4net-user@logging.apache.org
Sent: Mon, April 19, 2010 5:07:38 PM
Subject: Filters with AND/OR conditions.

  
I have 2 properties that I need to filter log messages based
upon.  I have setup an smtp appender for Error and Fatal log messages, but
a couple components didn’t implement logging properly and are logging
errors when they don’t exist.  That problem is being dealt
with.  So I’m trying to take care of those messages with filters. 
What is the best way to setup something like this:
 
If (Property1 = “111” && Property2 = “abc”
)  || 
    (Property1 = ”111” &&
Property2 = “bbb”) ||
    (Property1 = ”222” &&
Property2 = “def”) ||
    (Property1 = ”333” &&
Property2 = “xyz”))
Then
                Deny
Else
                Accept
 
 
Any help would be great.
 
Thanks,
Brian