<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi everyone,<div><br></div><div>I have developed a custom LogBack appender and I would like it to receive only log messages of a given level. I don't want to hard code it in the class, but to set it in the XML configuration file.</div><div><br></div><div>I thought something like this would work (but it doesn't):</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(56, 52, 255); "><span style="color: #009193"><</span><span style="color: #4d9192">root</span><span style="color: #000000"> </span><span style="color: #932192">level</span><span style="color: #000000">=</span>"trace"<span style="color: #009193">></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(77, 145, 146); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span><span style="color: #009193"><</span>appender-ref<span style="color: #000000"> </span><span style="color: #932192">ref</span><span style="color: #000000">=</span><span style="color: #3834ff">"FILE"</span><span style="color: #000000"> </span><span style="color: #009193">/></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(56, 52, 255); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span><span style="color: #009193"><</span><span style="color: #4d9192">appender-ref</span><span style="color: #000000"> </span><span style="color: #932192">ref</span><span style="color: #000000">=</span>"MyTraceAppender"<span style="color: #000000"> </span><span style="color: #009193">/></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(56, 52, 255); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"> </span></span><span style="color: #009193"><</span><span style="color: #4d9192">appender-ref</span><span style="color: #000000"> </span><span style="color: #932192">ref</span><span style="color: #000000">=</span>"MyInfoAppender" <span style="color: rgb(147, 33, 146); ">level</span><span style="color: rgb(0, 0, 0); ">=</span>"info"<span style="color: #009193">/></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(77, 145, 146); "><span style="color: #009193"></</span>root<span style="color: #009193">></span></div></div><div><br></div><div>I also tried something like:</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(56, 52, 255); "><span class="Apple-style-span"><span style="color: #009193"><</span><span style="color: #4d9192">appender</span><span style="color: #000000"> </span><span style="color: #932192">name</span><span style="color: #000000">=</span>"</span>MyTraceAppender<span class="Apple-style-span">"<span style="color: #000000"> </span><span style="color: #932192">class</span><span style="color: #000000">=</span>"org.test.MyLogger1"<span style="color: #009193">/></span></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(56, 52, 255); "><span class="Apple-style-span"><span style="color: #009193"><</span><span style="color: #4d9192">appender</span><span style="color: #000000"> </span><span style="color: #932192">name</span><span style="color: #000000">=</span>"</span>MyInfoAppender<span class="Apple-style-span">"<span style="color: #000000"> </span><span style="color: #932192">class</span><span style="color: #000000">=</span>"</span>org.test.MyLogger2<span class="Apple-style-span">"<span style="color: #000000"> </span><span style="color: #932192">level</span><span style="color: #000000">=</span>"info"<span style="color: #009193">/></span></span></div></div><div><br></div><div>No luck either.</div><div><br></div><div>It seems only loggers can be assigned a threshold level. So I though about something like this:</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(147, 33, 146); "><span style="color: #009193"><</span><span style="color: #4d9192">logger</span><span style="color: #000000"> </span>name<span style="color: #000000">=</span><span style="color: #3834ff">"test"</span><span style="color: #000000"> </span>level<span style="color: #000000">=</span><span style="color: #3834ff">"info"</span><span style="color: #009193">></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> <span style="color: rgb(0, 145, 147); "><</span><span style="color: rgb(77, 145, 146); ">appender-ref</span><span style="color: rgb(0, 0, 0); "> </span><span style="color: rgb(147, 33, 146); ">ref</span><span style="color: rgb(0, 0, 0); ">=</span><font class="Apple-style-span" color="#3834ff">"MyInfoAppender</font><span class="Apple-style-span" style="color: rgb(56, 52, 255); ">"<span style="color: #000000"> </span><span style="color: #009193">/></span></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(77, 145, 146); "><span style="color: #009193"></</span>logger<span style="color: #009193">></span></div></div><div><br></div><div>but this would only log messages sent by classes whose package is test. *... And I want to log anything.</div><div><br></div><div>Can anyone help?</div><div><br></div><div>Thanks</div><div>Ben</div></body></html>