Thanks for the prompt reply. 
I changed the configuration file as you suggested and invoked 
LoggerStatusPrinter.printStatusInDefaultContext() after the logging request. I 
received a lot of output and I included below the four lines that indicated an 
error.

The filter still does not give me the result that I'm looking for. I appreciate 
any help you can give me.

--
Yoram

|-ERROR in ch.qos.logback.core.joran.action.NestedComponentIA - No class name 
attribute in <evaluator>
|-ERROR in [EMAIL PROTECTED] - no applicable action for <expression>, current 
pattern is [/configuration/appender/filter/evaluator/expression]
|-ERROR in [EMAIL PROTECTED] - no applicable action for <OnMatch>, current 
pattern is [/configuration/appender/filter/OnMatch]
|-ERROR in [EMAIL PROTECTED] - No evaluator set for filter null
|

-----Original Message-----
From: Ceki Gülcü [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 20, 2006 3:46 PM
To: logback users list
Subject: Re: [logback-user] How To Use Filters


Yoram,

Thanks for using logback.

You can instruct logback-classic to tell you to print its internal
status with the following call:

   LoggerStatusPrinter.printStatusInDefaultContext();

This will print logback's internal error messages on the console.

You can achieve a similar affect in configuration files by setting the
debug attribute of the configuration element to true. For example:

<configuration debug="true">   <--- this line
   <appender name="STDOUT"
             class="ch.qos.logback.core.ConsoleAppender">
     <layout class="ch.qos.logback.classic.PatternLayout">
       <pattern>
         %d{HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n
       </pattern>
     </layout>
   </appender>
   <root>
     <level value="DEBUG" />
     <appender-ref ref="STDOUT" />
   </root>
</configuration>


When logback is done configuring itself using the above config file,
it will dump its internal status on the console.

Anyway, I'd first try invoking LoggerStatusPrinter's
printStatusInDefaultContext() after  the

   logger.debug(pcMarker, "Cnfiguration...")

call and see what logback tells you.

My guess is that it will complain about exceptions thrown by the
expression evaluator because marker is null. Try changing the
expressions to

    <evaluator name="myEval">
      <expression>(marker != null) &amp;&amp; 
(marker.contains("printConfiguration"))</expression>
    </evaluator>
    <OnMismatch>NEUTRAL</OnMismatch>
    <OnMatch>DENY</OnMatch>

The &amp;&amp; combination represents Java's expression for logical AND,
that is '&&', which you cannot write as is in XML files.

Please let us know how it goes.


At 08:18 PM 12/20/2006, Yoram Forscher wrote:
>After reading chapter 6, "Filter Chains," I tried to use some filters 
>myself with no success. My configuration file contains the following:
>
><appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
><filter class="ch.qos.logback.core.filter.EvaluatorFilter">
>                         <evaluator name="myEval">
> 
><expression>marker.getName().equals("printConfiguration")</expression>
>                         </evaluator>
>                         <OnMismatch>NEUTRAL</OnMismatch>
>                         <OnMatch>DENY</OnMatch>
>             </filter>
>             <layout class="ch.qos.logback.classic.PatternLayout">
>                         <param name="pattern" value="%d{ISO8601} %-5p 
> [%c{40}] %m%n"/>
>             </layout>
></appender>
>
>In my code I have the following:
>private Marker pcMarker = MarkerFactory.getMarker("printConfiguration");
>...
>logger.debug(pcMarker, "Configuration Information");
>...
>
>I expect in that case that no output will be created, but it keeps 
>printing it regardless of how I set it up. I also tried to change the 
>expression to 'marker.contains("printConfiguration")' and change the 
>OnMismatch and OnMatch both to DENY. Same result.
>
>What am I doing wrong?

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch


_______________________________________________
Logback-user mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-user

Reply via email to