[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4j-user
Subject:    RE: Logging custom levels using log4j
From:       "Scott Deboy" <sdeboy () comotivsystems ! com>
Date:       2005-12-30 17:53:19
Message-ID: E45E5CC99D174847A32B0970834F177C38A65F () csicorp6 ! pdxcsi ! com
[Download RAW message or body]

I don't think you can specify filters in the properties file format - use an xml config file instead.

Here's an example:

<appender name="someAppender" class="org.apache.log4j.FileAppender">
     <layout class="org.apache.log4j.SimpleLayout"/>
  <filter class="org.apache.log4j.varia.ExpressionFilter">
        <param name="Expression" value="msg ~= blah" />
        <param name="AcceptOnMatch" value="true"/>
        <param name="ConvertInFixToPostFix" value="true"/>
  </filter>
  <filter class="org.apache.log4j.varia.DenyAllFilter"/>
  </appender>

The denyallfilter makes sure the events are dropped if they weren't accepted by the expression filter.

Scott

-----Original Message-----
From: Praveen Kumar Hasthalapuram [mailto:praveen.hasthal@gmail.com]
Sent: Fri 12/30/2005 6:46 AM
To: Log4J Users List
Subject: Re: Logging custom levels using log4j
 
Hi ,

We are using Struts framework for our product(application) and using
logj.properties file to configure logging.

How can i configure Expression-based filters in log4j.properties? Is it
possible to configure in properties file?

One more basic question, Can we use both log4j.properties and log4j.xml file
to configure for an application?
Could anyone clarify me.

Thanks
-Praveen

On 12/29/05, Praveen Kumar Hasthalapuram <praveen.hasthal@gmail.com> wrote:
>
> Thanks Scott,
>
> I think this will help me.
>
> Regards,
> Praveen
>
>  On 12/29/05, Scott Deboy <sdeboy@comotivsystems.com> wrote:
>
> > You can do this using log4j 1.3 using ExpressionFilter, or you could
> > write your own filter that does the same thing.
> >
> > Route all the events to both file appenders, and specify a different
> > ExpressionFilter on each appender.
> >
> > An example expression you would use with ExpressionFilter:
> > MSG ~= SNMP
> >
> > Remember to put spaces around the operators, etc.
> >
> > You can find out more information on the expression syntax by viewing
> > Chainsaw V2's tutorial:
> > http://logging.apache.org/log4j/docs/chainsaw.html
> >
> > Scott
> >
> > -----Original Message-----
> > From: Praveen Kumar Hasthalapuram [mailto:praveen.hasthal@gmail.com]
> > Sent: Thu 12/29/2005 9:17 AM
> > To: log4j-user@logging.apache.org
> > Subject: Logging custom levels using log4j
> >
> > Hi All,
> > I need to log specified particular type of messages to one log file and
> > rest
> > to another log file.
> > For example say,  if message contains "SNMP" or "CDP" and so on, need to
> > log
> > in to log1.log and
> > rest of the messages need to log in to log2.log
> > How to configure the log4j.properties to log custom levels?
> > Is there any provision  to create custom levels and to configure it?
> >
> > I heard that we can do this with the use of Filters.
> >
> > Could anyone suggest me better solution for this.
> >
> > Thanks in Advance,
> > Praveen
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>




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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic