[logback-user] How can I monitor the actual size of the asyncappender queue?

haobo liu lhbazazazv at gmail.com
Sat May 29 03:00:53 CEST 2021


The code like

LoggerContext loggerContext  = (LoggerContext)
LoggerFactory.getILoggerFactory();
ch.qos.logback.classic.Logger logger =
loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
AsyncAppender sync = (AsyncAppender) logger.getAppender("async");
int numberOfElementsInQueue = sync.getNumberOfElementsInQueue();


KARR, DAVID <dk068x at att.com> 于2021年5月28日周五 下午11:09写道:

> 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.
>
>
>
> *From:* logback-user <logback-user-bounces at qos.ch> *On Behalf Of *haobo
> liu
> *Sent:* Thursday, May 27, 2021 11:52 PM
> *To:* logback users list <logback-user at qos.ch>
> *Subject:* Re: [logback-user] How can I monitor the actual size of the
> asyncappender queue?
>
>
>
> in xml the name like
> <appender name="async" class="ch.qos.logback.classic.AsyncAppender">
>     <queueSize>500</queueSize>
>     <discardingThreshold>0</discardingThreshold>
>     <appender-ref ref="info"/>
> </appender>
>
> KARR, DAVID <dk068x at att.com> 于2021年5月28日周五 下午1:32写道:
>
>
>
> KARR, DAVID <dk068x at att.com> 于2021年5月28日周五 下午1:32写道:
>
> > -----Original Message-----
> > From: logback-user <logback-user-bounces at qos.ch> On Behalf Of haobo liu
> > Sent: Thursday, May 27, 2021 6:30 PM
> > To: logback users list <logback-user at qos.ch>
> > Subject: Re: [logback-user] How can I monitor the actual size of the
> > asyncappender queue?
> >
> > maybe ch.qos.logback.core.AsyncAppenderBase#getNumberOfElementsInQueue
> >  or hack the code add a volatile variable (bad idea)
>
> 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?
>
> 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?
>
> > KARR, DAVID <dk068x at att.com> 于2021年5月28日周五 上午12:02写道:
> > >
> > > I believe I now understand the basic mechanics of the AsyncAppender
> > queue, and the tradeoffs of having it small or large.
> > >
> > > What's not obvious to me is how I can monitor the utilization of the
> > queue, perhaps in a load test.  I did notice there is a "listener"
> > mechanism, and one example I believe illustrates how I can detect when
> > logs are dropped because the queue is full, but I want to get an idea of
> > how well the queue size is being utilized, or how close it's getting to
> > being full.
> > > _______________________________________________
> > > logback-user mailing list
> > > logback-user at qos.ch
> > >
> > https://urldefense.com/v3/__http://mailman.qos.ch/mailman/listinfo/logba
> <https://urldefense.com/v3/__http:/mailman.qos.ch/mailman/listinfo/logba>
> > ck-user__;!!BhdT!3fKeEphTUa7E0aTa8d_CL5pew3dk2J9fS4P9e8p-
> > IzfqusHDdGdZTnCCLSQO_g$
> > _______________________________________________
> > logback-user mailing list
> > logback-user at qos.ch
> > https://urldefense.com/v3/__http://mailman.qos.ch/mailman/listinfo/logba
> <https://urldefense.com/v3/__http:/mailman.qos.ch/mailman/listinfo/logba>
> > ck-user__;!!BhdT!3fKeEphTUa7E0aTa8d_CL5pew3dk2J9fS4P9e8p-
> > IzfqusHDdGdZTnCCLSQO_g$
> _______________________________________________
> logback-user mailing list
> logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
> <https://urldefense.com/v3/__http:/mailman.qos.ch/mailman/listinfo/logback-user__;!!BhdT!zygZD28LPoEstVsFzbGd9YZbR4R-9OFO2K2ki5wJ9Np-MfEUCNBA43VFEuCv-A$>
>
> _______________________________________________
> logback-user mailing list
> logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20210529/d5fa01b1/attachment-0001.html>


More information about the logback-user mailing list