<div dir="ltr">The code like <div><pre style="background-color:rgb(39,40,34);color:rgb(207,191,173);font-family:"Source Code Pro";font-size:12.8pt"><span style="color:rgb(82,227,246)">LoggerContext </span>loggerContext  <span style="color:rgb(255,0,127)">= </span><span style="color:rgb(249,250,244)">(</span><span style="color:rgb(82,227,246)">LoggerContext</span><span style="color:rgb(249,250,244)">) </span><span style="color:rgb(82,227,246)">LoggerFactory</span><span style="color:rgb(255,0,127)">.</span>getILoggerFactory<span style="color:rgb(249,250,244)">()</span><span style="color:rgb(255,0,127)">;<br></span><span style="color:rgb(82,227,246)">ch.qos.logback.classic.Logger </span>logger <span style="color:rgb(255,0,127)">= </span>loggerContext<span style="color:rgb(255,0,127)">.</span><span style="color:rgb(167,236,33)">getLogger</span><span style="color:rgb(249,250,244)">(</span><span style="color:rgb(82,227,246)">Logger</span><span style="color:rgb(255,0,127)">.</span><span style="color:rgb(25,72,166);font-weight:bold;font-style:italic">ROOT_LOGGER_NAME</span><span style="color:rgb(249,250,244)">)</span><span style="color:rgb(255,0,127)">;<br></span><span style="color:rgb(82,227,246)">AsyncAppender </span>sync <span style="color:rgb(255,0,127)">= </span><span style="color:rgb(249,250,244)">(</span><span style="color:rgb(82,227,246)">AsyncAppender</span><span style="color:rgb(249,250,244)">) </span>logger<span style="color:rgb(255,0,127)">.</span><span style="color:rgb(167,236,33)">getAppender</span><span style="color:rgb(249,250,244)">(</span><span style="color:rgb(236,228,126)">"async"</span><span style="color:rgb(249,250,244)">)</span><span style="color:rgb(255,0,127)">;<br></span><span style="color:rgb(255,0,127)">int </span>numberOfElementsInQueue <span style="color:rgb(255,0,127)">= </span>sync<span style="color:rgb(255,0,127)">.</span><span style="color:rgb(167,236,33)">getNumberOfElementsInQueue</span><span style="color:rgb(249,250,244)">()</span><span style="color:rgb(255,0,127)">;</span></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">KARR, DAVID <<a href="mailto:dk068x@att.com">dk068x@att.com</a>> 于2021年5月28日周五 下午11:09写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_767029356980078534WordSection1">
<p class="MsoNormal">Thanks for replying, but I think you’re missing the point.  I’m well aware of how to define an AsyncAppender.  I’m investigating how to properly monitor the size of the queue.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> logback-user <<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a>> <b>On Behalf Of
</b>haobo liu<br>
<b>Sent:</b> Thursday, May 27, 2021 11:52 PM<br>
<b>To:</b> logback users list <<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a>><br>
<b>Subject:</b> Re: [logback-user] How can I monitor the actual size of the asyncappender queue?<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">in xml the name like<br>
<appender name="<span style="color:black;background:red">async</span>" class="ch.qos.logback.classic.AsyncAppender"><br>
    <queueSize>500</queueSize><br>
    <discardingThreshold>0</discardingThreshold><br>
    <appender-ref ref="info"/><br>
</appender><br>
<br>
KARR, DAVID <<a href="mailto:dk068x@att.com" target="_blank">dk068x@att.com</a>> <span style="font-family:"MS Gothic"">
于</span>2021<span style="font-family:"MS Gothic"">年</span>5<span style="font-family:"MS Gothic"">月</span>28<span style="font-family:"MS Gothic"">日周五</span>
<span style="font-family:"MS Gothic"">下午</span>1:32<span style="font-family:"MS Gothic"">写道:</span><u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12pt"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">KARR, DAVID <<a href="mailto:dk068x@att.com" target="_blank">dk068x@att.com</a>>
<span style="font-family:"MS Gothic"">于</span>2021<span style="font-family:"MS Gothic"">年</span>5<span style="font-family:"MS Gothic"">月</span>28<span style="font-family:"MS Gothic"">日周五</span>
<span style="font-family:"MS Gothic"">下午</span>1:32<span style="font-family:"MS Gothic"">写道:</span><u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">> -----Original Message-----<br>
> From: logback-user <<a href="mailto:logback-user-bounces@qos.ch" target="_blank">logback-user-bounces@qos.ch</a>> On Behalf Of haobo liu<br>
> Sent: Thursday, May 27, 2021 6:30 PM<br>
> To: logback users list <<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a>><br>
> Subject: Re: [logback-user] How can I monitor the actual size of the<br>
> asyncappender queue?<br>
> <br>
> maybe ch.qos.logback.core.AsyncAppenderBase#getNumberOfElementsInQueue<br>
>  or hack the code add a volatile variable (bad idea)<br>
<br>
Ok, then the next question is how do I access this from code?  I see that Logger's base hierarchy has a "getAppender(String)" method.  What is the input parameter for that?<br>
<br>
Once I solve that, I guess I have to think about whether it makes sense to write occasional log messages that print the current queue size (which would obviously go into the queue).  I wonder if I can render it in a JMX property?<br>
<br>
> KARR, DAVID <<a href="mailto:dk068x@att.com" target="_blank">dk068x@att.com</a>>
<span style="font-family:"MS Gothic"">于</span>2021<span style="font-family:"MS Gothic"">年</span>5<span style="font-family:"MS Gothic"">月</span>28<span style="font-family:"MS Gothic"">日周五</span>
<span style="font-family:"MS Gothic"">上午</span>12:02<span style="font-family:"MS Gothic"">写道:</span><br>
> ><br>
> > I believe I now understand the basic mechanics of the AsyncAppender<br>
> queue, and the tradeoffs of having it small or large.<br>
> ><br>
> > What's not obvious to me is how I can monitor the utilization of the<br>
> queue, perhaps in a load test.  I did notice there is a "listener"<br>
> mechanism, and one example I believe illustrates how I can detect when<br>
> logs are dropped because the queue is full, but I want to get an idea of<br>
> how well the queue size is being utilized, or how close it's getting to<br>
> being full.<br>
> > _______________________________________________<br>
> > logback-user mailing list<br>
> > <a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a><br>
> ><br>
> <a href="https://urldefense.com/v3/__http:/mailman.qos.ch/mailman/listinfo/logba" target="_blank">
https://urldefense.com/v3/__http://mailman.qos.ch/mailman/listinfo/logba</a><br>
> ck-user__;!!BhdT!3fKeEphTUa7E0aTa8d_CL5pew3dk2J9fS4P9e8p-<br>
> IzfqusHDdGdZTnCCLSQO_g$<br>
> _______________________________________________<br>
> logback-user mailing list<br>
> <a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a><br>
> <a href="https://urldefense.com/v3/__http:/mailman.qos.ch/mailman/listinfo/logba" target="_blank">
https://urldefense.com/v3/__http://mailman.qos.ch/mailman/listinfo/logba</a><br>
> ck-user__;!!BhdT!3fKeEphTUa7E0aTa8d_CL5pew3dk2J9fS4P9e8p-<br>
> IzfqusHDdGdZTnCCLSQO_g$<br>
_______________________________________________<br>
logback-user mailing list<br>
<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a><br>
<a href="https://urldefense.com/v3/__http:/mailman.qos.ch/mailman/listinfo/logback-user__;!!BhdT!zygZD28LPoEstVsFzbGd9YZbR4R-9OFO2K2ki5wJ9Np-MfEUCNBA43VFEuCv-A$" target="_blank">http://mailman.qos.ch/mailman/listinfo/logback-user</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>
</div>

_______________________________________________<br>
logback-user mailing list<br>
<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/logback-user" rel="noreferrer" target="_blank">http://mailman.qos.ch/mailman/listinfo/logback-user</a></blockquote></div>