Why not make a logger just for method2? Something like this might do it for you:<div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><font size="2" face="sans-serif">public Class D{</font> <br>
<br><font size="2" face="sans-serif"> Logger logger = LoggerFactory.getLogger(D.class);</font> </span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><meta http-equiv="content-type" content="text/html; charset=utf-8"><font size="2" face="sans-serif"> Logger loggerForMethod2 = LoggerFactory.getLogger(</font></span><span class="Apple-style-span" style="font-family: 'Courier New'; border-collapse: collapse; color: rgb(66, 0, 255); "><i><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: sans-serif; font-style: normal; ">D.class + "</span>#method2"</i></span><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><font size="2" face="sans-serif">);</font> </span></div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><span class="Apple-style-span" style="border-collapse: collapse; "><br><font size="2" face="sans-serif" style="font-family: arial, sans-serif; font-size: 13px; "> public void method1(){</font><font class="Apple-style-span" face="arial, sans-serif"> </font><br>
<font size="2" face="sans-serif" style="font-family: arial, sans-serif; font-size: 13px; "> <a href="http://logger.info/" target="_blank" style="color: rgb(87, 151, 176); ">logger.info</a>("method1");</font><font class="Apple-style-span" face="arial, sans-serif"> </font><br>
<font size="2" face="sans-serif" style="font-family: arial, sans-serif; font-size: 13px; "> }</font><font class="Apple-style-span" face="arial, sans-serif"> </font><br><br><font size="2" face="sans-serif" style="font-family: arial, sans-serif; font-size: 13px; "> public void method2(){</font><font class="Apple-style-span" face="arial, sans-serif"> </font><br>
<font size="2" face="sans-serif" style="font-family: arial, sans-serif; font-size: 13px; "> <a href="http://logger.info/" target="_blank" style="color: rgb(87, 151, 176); ">logger.info</a>("method2");</font><font class="Apple-style-span" face="arial, sans-serif"> </font><br>
<font size="2" face="sans-serif" style="font-family: arial, sans-serif; font-size: 13px; "> }</font><font class="Apple-style-span" face="arial, sans-serif"> </font><br><font size="2" face="sans-serif" style="font-family: arial, sans-serif; font-size: 13px; ">}</font><font class="Apple-style-span" face="arial, sans-serif"> </font><br>
</span><br><div class="gmail_quote">On Mon, Sep 20, 2010 at 10:21 AM, <span dir="ltr"><<a href="mailto:marc.baumgartner@degussa-bank.de">marc.baumgartner@degussa-bank.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font size="2" face="sans-serif">Hi all,</font>
<br>
<br><font size="2" face="sans-serif">is there a possibility to log depending
on the class or method? For example I have the following scenario:</font>
<br>
<br><font size="2" face="sans-serif">package a.b.c</font>
<br>
<br><font size="2" face="sans-serif">public Class D{</font>
<br>
<br><font size="2" face="sans-serif"> Logger
logger = LoggerFactory.getLogger(D.class);</font>
<br>
<br><font size="2" face="sans-serif"> public
void method1(){</font>
<br><font size="2" face="sans-serif">
<a href="http://logger.info" target="_blank">logger.info</a>("method1");</font>
<br><font size="2" face="sans-serif"> }</font>
<br>
<br><font size="2" face="sans-serif"> public
void method2(){</font>
<br><font size="2" face="sans-serif">
<a href="http://logger.info" target="_blank">logger.info</a>("method2");</font>
<br><font size="2" face="sans-serif"> }</font>
<br><font size="2" face="sans-serif">}</font>
<br>
<br><font size="2" face="sans-serif">I look for something like this in logback
configuration:</font>
<br>
<br><font size="2" color="#008080" face="Courier New"><</font><font size="2" color="#3f8080" face="Courier New">logger</font><font size="2" face="Courier New">
</font><font size="2" color="#800080" face="Courier New">name</font><font size="2" face="Courier New">=</font><font size="2" color="#4200ff" face="Courier New"><i>"a.b.c.D#method1"</i></font><font size="2" face="Courier New">
</font><font size="2" color="#800080" face="Courier New">level</font><font size="2" face="Courier New">=</font><font size="2" color="#4200ff" face="Courier New"><i>"INFO"</i></font><font size="2" face="Courier New">
</font><font size="2" color="#008080" face="Courier New">/></font>
<br>
<br><font size="2" color="#008080" face="Courier New"><</font><font size="2" color="#3f8080" face="Courier New">root</font><font size="2" face="Courier New">
</font><font size="2" color="#800080" face="Courier New">level</font><font size="2" face="Courier New">=</font><font size="2" color="#4200ff" face="Courier New"><i>"WARN"</i></font><font size="2" color="#008080" face="Courier New">></font>
<br><font size="2" color="#008080" face="Courier New"></root></font>
<br>
<br>
<br><font size="2" color="#008080" face="Courier New">After calling method1
and method2 I would expect only the log entry of method 2.</font>
<br>
<br><font size="2" color="#008080" face="Courier New">Is this possible?</font>
<br>
<br><font size="2" color="#008080" face="Courier New">Thanks & regards,</font>
<br><font size="2" color="#008080" face="Courier New">Marc</font>
<br><br>_______________________________________________<br>
Logback-user mailing list<br>
<a href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a><br>
<a href="http://qos.ch/mailman/listinfo/logback-user" target="_blank">http://qos.ch/mailman/listinfo/logback-user</a><br>
<br></blockquote></div><br></div>