Yes, you only need to include a logger if you need to change something for it.

On 1/9/06, Praveen Kumar Hasthalapuram <[EMAIL PROTECTED]> wrote:
> We have various modules in my appln, in which one of the module needs
> filtering of messages.
>
> So, we need to mention the package name (com.mapack) to filter for that
> particular package only right?
>
> If not, how can we specify or differentiate from other appenders in config
> file.
>
> Let me know if i am wrong.
>
>
> Thanks,
> Praveen
>
>
>
> On 1/8/06, James Stauffer <[EMAIL PROTECTED]> wrote:
> >
> > I don't know why you would get extra space characters.  Given what you
> > show, there is no reason to have the com.mypack logger in the config
> > file.
> > On 1/7/06, Praveen Kumar Hasthalapuram <[EMAIL PROTECTED]> wrote:
> > > Thanks James, it is working now.
> > >
> > > But some times i could see empty space (characters) getting appended in
> > > respective log files.
> > >
> > > I have modified some thing like this:
> > >    <logger name="com.mypack" additivity="false">
> > >      <level value="debug"/>
> > >         <appender-ref ref="P"/>
> > >         <appender-ref ref="PA"/>
> > >     </logger>
> > >
> > >    <root>
> > >     <priority value ="debug"/>
> > >     <appender-ref ref="P"/>
> > >     <appender-ref ref="PA"/>
> > >   </root>
> > >
> > > What could be the reason?
> > >
> > > Regards,
> > > Praveen
> > >
> > > On 1/5/06, James Stauffer <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Change your config to include the logger/category in the output.  When
> > > > you find the logger of the bad messages, change your config to not log
> > > > them (or only log warn and above).
> > > >
> > > > On 1/5/06, Praveen Kumar Hasthalapuram <[EMAIL PROTECTED]>
> > wrote:
> > > > > Hi All,
> > > > >
> > > > > I have a Filter class (StringMatchFilter.java) which will filter for
> > > > > specific message.
> > > > > By default i will log all the messages to one log file (file1.log)
> > and
> > > > > if particular string matches (based on defined filter) it should
> > logto
> > > > > file1.log and
> > > > > another log file (file1.log) too.
> > > > >
> > > > > I have configured in log4j.xml for it as shown below.
> > > > >
> > > > > Filtering is working , but whenever i restart tomcat some junk data
> > > > > related to Tomcat server is also getting logged into this file and
> > > > > some times empty spaces are getting occupied in the file1.log and
> > > > > file2.log.
> > > > >
> > > > > Sample junk data: [2006-01-05 20:54:56] [DEBUG] ignorableWhitespace(
> > > > > )
> > > > > [2006-01-05 20:54:56] [DEBUG] startElement(,,rtexprvalue)
> > > > > [2006-01-05 20:54:56] [DEBUG]   Pushing body text ''
> > > > > [2006-01-05 20:54:56] [DEBUG]   New
> > > > match='taglib/tag/attribute/rtexprvalue'
> > > > > [2006-01-05 20:54:56] [DEBUG]   No rules found matching
> > > > > 'taglib/tag/attribute/rtexprvalue'.
> > > > > [2006-01-05 20:54:56] [DEBUG] characters(true)
> > > > > [2006-01-05 20:54:56] [DEBUG] endElement(,,rtexprvalue)
> > > > > [2006-01-05 20:54:56] [DEBUG]
> > match='taglib/tag/attribute/rtexprvalue'
> > > > > [2006-01-05 20:54:56] [DEBUG]   bodyText='true'
> > > > > [2006-01-05 20:54:56] [DEBUG]   No rules found matching
> > > > > 'taglib/tag/attribute/rtexprvalue'.
> > > > > [2006-01-05 20:54:56] [DEBUG]   Popping body text ''
> > > > > [2006-01-05 20:54:56] [DEBUG] ignorableWhitespace(
> > > > > )
> > > > > [2006-01-05 20:54:56] [DEBUG] endElement(,,attribute)
> > > > > [2006-01-05 20:54:56] [DEBUG]   match='taglib/tag/attribute'
> > > > > [2006-01-05 20:54:56] [DEBUG]   bodyText=''
> > > > > [2006-01-05 20:54:56] [DEBUG]   No rules found matching
> > > > 'taglib/tag/attribute'
> > > > >
> > > > >
> > > > > Because of it file size is grwoing like anything. Even not backing
> > up
> > > > files.
> > > > >
> > > > > What could be the problem? is it in configuration or in filter class
> > > > file?
> > > > >
> > > > > Could anyone suggest me?
> > > > >
> > > > > Here iam listing sample xml file and java file:
> > > > >
> > > > > log4j.xml
> > > > >
> > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> > > > >
> > > > > <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/";>
> > > > >
> > > > >
> > > > >    <!-- MyPackage Rolling Log -->
> > > > >     <appender name="P" class="org.apache.log4j.RollingFileAppender">
> > > > >         <param name="Threshold" value="DEBUG"/>
> > > > >         <param name="File" value="file1.log"/>
> > > > >         <param name="Append" value="true"/>
> > > > >         <param name="MaxFileSize" value="10MB"/>
> > > > >         <param name="maxBackupIndex" value="2"/>
> > > > >         <layout class="org.apache.log4j.PatternLayout">
> > > > >             <param name="ConversionPattern" value="[%d{yyyy-MM-dd
> > > > > HH:mm:ss}] [%p] %m%n"/>
> > > > >         </layout>
> > > > >     </appender>
> > > > >
> > > > >    <!-- MyPackage Rolling Log -->
> > > > >     <appender name="PA" class="org.apache.log4j.RollingFileAppender
> > ">
> > > > >         <param name="File" value="file2.log"/>
> > > > >         <param name="Append" value="true"/>
> > > > >         <param name="MaxFileSize" value="10MB"/>
> > > > >         <param name="maxBackupIndex" value="10"/>
> > > > >         <layout class="org.apache.log4j.PatternLayout">
> > > > >             <param name="ConversionPattern" value="[%d{yyyy-MM-dd
> > > > > HH:mm:ss}] [%p] %m%n"/>
> > > > >         </layout>
> > > > >           <filter class="
> > > > com.cisco.nettools.logger.filters.StringMatchFilter">
> > > > >             <param name="stringToMatch" value="SNMP"/>
> > > > >             <param name="matchReturnValue" value="accept"/>
> > > > >             <param name="noMatchReturnValue" value="deny"/>
> > > > >           </filter>
> > > > >     </appender>
> > > > >
> > > > >
> > > > >     <!-- MyPackage Logger (three packages) -->
> > > > >     <logger name="com.mypack1" additivity="false">
> > > > >         <appender-ref ref="P"/>
> > > > >         <appender-ref ref="PA"/>
> > > > >     </logger>
> > > > >
> > > > >     <logger name="com.mypack2" additivity="false">
> > > > >         <appender-ref ref="P"/>
> > > > >         <appender-ref ref="PA"/>
> > > > >     </logger>
> > > > >
> > > > >     <logger name="com.mypack3" additivity="false">
> > > > >         <appender-ref ref="P"/>
> > > > >         <appender-ref ref="PA"/>
> > > > >     </logger>
> > > > >
> > > > >  <!-- Set root logger level to DEBUG and its only appender to P, PA
> > -->
> > > > >
> > > > >   <root>
> > > > >     <priority value ="debug"/>
> > > > >     <appender-ref ref="P"/>
> > > > >     <appender-ref ref="PA"/>
> > > > >   </root>
> > > > >
> > > > > </log4j:configuration>
> > > > >
> > > > >
> > > > >
> > > > > StringMatchFilter.java
> > > > > ----------------------
> > > > >
> > > > >   package com.mypackage.logger.filters;
> > > > >
> > > > >   import org.apache.log4j.spi.Filter;
> > > > >   import org.apache.log4j.spi.LoggingEvent;
> > > > >
> > > > >
> > > > >   public class StringMatchFilter extends Filter {
> > > > >
> > > > >         boolean acceptOnMatch = true;
> > > > >         String stringToMatch;
> > > > >         public int matchReturnValue = Filter.ACCEPT;
> > > > >         public int noMatchReturnValue = Filter.DENY;
> > > > >         public int cantMatchReturnValue = Filter.NEUTRAL;
> > > > >
> > > > >         protected int calcFilterReturnValue(String value) {
> > > > >                 if ("accept".equalsIgnoreCase(value))
> > > > >                         return Filter.ACCEPT;
> > > > >                 else if ("deny".equalsIgnoreCase(value))
> > > > >                         return Filter.DENY;
> > > > >                 else
> > > > >                         return Filter.NEUTRAL;
> > > > >         }
> > > > >
> > > > >         public void setMatchReturnValue(String value) {
> > > > >                 matchReturnValue = calcFilterReturnValue(value);
> > > > >         }
> > > > >
> > > > >
> > > > >         public void setNoMatchReturnValue(String value) {
> > > > >                 noMatchReturnValue = calcFilterReturnValue(value);
> > > > >         }
> > > > >
> > > > >
> > > > >         public void setCantReturnValue(String value) {
> > > > >                 cantMatchReturnValue = calcFilterReturnValue(value);
> > > > >         }
> > > > >
> > > > >
> > > > >     public void setStringToMatch(String s) {
> > > > >         stringToMatch = s;
> > > > >     }
> > > > >
> > > > >     public String getStringToMatch() {
> > > > >       return stringToMatch;
> > > > >     }
> > > > >
> > > > >     public void setAcceptOnMatch(boolean acceptOnMatch) {
> > > > >       this.acceptOnMatch = acceptOnMatch;
> > > > >     }
> > > > >
> > > > >     public boolean getAcceptOnMatch() {
> > > > >       return acceptOnMatch;
> > > > >     }
> > > > >
> > > > >
> > > > >     public int decide(LoggingEvent event) {
> > > > >         String msg = event.getRenderedMessage();
> > > > >         if(msg == null ||  stringToMatch == null){
> > > > >                 return cantMatchReturnValue;
> > > > >         }
> > > > >
> > > > >
> > > > >         if(msg.indexOf(stringToMatch) >= 0){
> > > > >                 System.out.println("String Matched");
> > > > >                 return matchReturnValue;
> > > > >         }else{
> > > > >                 System.out.println("String not matched");
> > > > >                 return noMatchReturnValue;
> > > > >         }
> > > > >     }
> > > > > }
> > > > >
> > > > >
> > > > > Thanks In Advance,
> > > > > Praveen
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > James Stauffer
> > > > Are you good? Take the test at http://www.livingwaters.com/good/
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > James Stauffer
> > Are you good? Take the test at http://www.livingwaters.com/good/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to