You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by 流子℡ <41...@qq.com> on 2015/10/19 12:01:43 UTC
回复:Difference between and -DAsyncLoggerContextSelector
if you set -DAsyncLoggerContextSelector ,all the asyncRoot node should be changed to Root, because needn't.
the difference is set DAsyncLoggerContextSelector make all the logger async,however. asyncRoot only make async inclued in the node.
------------------ 原始邮件 ------------------
发件人: "Strong Su";<lo...@gmail.com>;
发送时间: 2015年10月19日(星期一) 下午5:57
收件人: "Log4J Users List"<lo...@logging.apache.org>;
主题: Difference between <asyncRoot> and -DAsyncLoggerContextSelector
Hello everyone,
I'm not pretty sure about the difference <asyncRoot>
and -DAsyncLoggerContextSelector.
Here is a small slice example of log4j2.xml:
<Loggers>
<logger name="Class_A" level="info" additivity="false"/>
<root level="info/>
</Loggers>
When I set -DAsyncLoggerContextSelector, and both Class_A's logs and other
logs(like Class_B) should be async because the JAVA_OPTS makes all loggers
async..
But if I do not set -DAsyncLoggerContextSelector and change root to
asyncroot.
Should logs from Class_A be async or sync?
And what will happen if I remove additivity="false"?
Thank you.
Best Regards,
Dylan Su
Re: Difference between and -DAsyncLoggerContextSelector
Posted by Strong Su <lo...@gmail.com>.
Thank you very much guys.
On Mon, Oct 19, 2015 at 9:36 PM, Remko Popma <re...@gmail.com> wrote:
> Agreed: if you
> use
> -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
> then *all* loggers will be async.
>
> If you do not use the -DLog4jContextSelector=... system property then only
> loggers configured with <AsyncRoot> or <AsyncLogger> will be async and
> the loggers configured as <Logger> will be synchronous.
>
> In your example:
> <Loggers>
> <logger name="Class_A" level="info" additivity="false"><AppenderRef
> ref="A" /></Logger>
> <AsyncRoot level="info><AppenderRef ref="A" /></AsyncRoot>
> </Loggers>
>
> LogManager.getLogger("Class_A").info("some message"); // this is logged
> synchronously
>
> If additivity=true, the event will be processed both by the root logger
> (asynchronously) and by the Class_A logger (synchronously).
>
> Remko
>
>
> On Mon, Oct 19, 2015 at 7:01 PM, 流子℡ <41...@qq.com> wrote:
>
> > if you set -DAsyncLoggerContextSelector ,all the asyncRoot node should be
> > changed to Root, because needn't.
> > the difference is set DAsyncLoggerContextSelector make all the logger
> > async,however. asyncRoot only make async inclued in the node.
> >
> >
> >
> >
> > ------------------ 原始邮件 ------------------
> > 发件人: "Strong Su";<lo...@gmail.com>;
> > 发送时间: 2015年10月19日(星期一) 下午5:57
> > 收件人: "Log4J Users List"<lo...@logging.apache.org>;
> >
> > 主题: Difference between <asyncRoot> and -DAsyncLoggerContextSelector
> >
> >
> >
> > Hello everyone,
> >
> > I'm not pretty sure about the difference <asyncRoot>
> > and -DAsyncLoggerContextSelector.
> > Here is a small slice example of log4j2.xml:
> >
> > <Loggers>
> > <logger name="Class_A" level="info" additivity="false"/>
> > <root level="info/>
> > </Loggers>
> >
> > When I set -DAsyncLoggerContextSelector, and both Class_A's logs and
> other
> > logs(like Class_B) should be async because the JAVA_OPTS makes all
> loggers
> > async..
> > But if I do not set -DAsyncLoggerContextSelector and change root to
> > asyncroot.
> > Should logs from Class_A be async or sync?
> > And what will happen if I remove additivity="false"?
> >
> > Thank you.
> > Best Regards,
> > Dylan Su
> >
>
Re: Difference between and -DAsyncLoggerContextSelector
Posted by Remko Popma <re...@gmail.com>.
Agreed: if you
use -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
then *all* loggers will be async.
If you do not use the -DLog4jContextSelector=... system property then only
loggers configured with <AsyncRoot> or <AsyncLogger> will be async and
the loggers configured as <Logger> will be synchronous.
In your example:
<Loggers>
<logger name="Class_A" level="info" additivity="false"><AppenderRef
ref="A" /></Logger>
<AsyncRoot level="info><AppenderRef ref="A" /></AsyncRoot>
</Loggers>
LogManager.getLogger("Class_A").info("some message"); // this is logged
synchronously
If additivity=true, the event will be processed both by the root logger
(asynchronously) and by the Class_A logger (synchronously).
Remko
On Mon, Oct 19, 2015 at 7:01 PM, 流子℡ <41...@qq.com> wrote:
> if you set -DAsyncLoggerContextSelector ,all the asyncRoot node should be
> changed to Root, because needn't.
> the difference is set DAsyncLoggerContextSelector make all the logger
> async,however. asyncRoot only make async inclued in the node.
>
>
>
>
> ------------------ 原始邮件 ------------------
> 发件人: "Strong Su";<lo...@gmail.com>;
> 发送时间: 2015年10月19日(星期一) 下午5:57
> 收件人: "Log4J Users List"<lo...@logging.apache.org>;
>
> 主题: Difference between <asyncRoot> and -DAsyncLoggerContextSelector
>
>
>
> Hello everyone,
>
> I'm not pretty sure about the difference <asyncRoot>
> and -DAsyncLoggerContextSelector.
> Here is a small slice example of log4j2.xml:
>
> <Loggers>
> <logger name="Class_A" level="info" additivity="false"/>
> <root level="info/>
> </Loggers>
>
> When I set -DAsyncLoggerContextSelector, and both Class_A's logs and other
> logs(like Class_B) should be async because the JAVA_OPTS makes all loggers
> async..
> But if I do not set -DAsyncLoggerContextSelector and change root to
> asyncroot.
> Should logs from Class_A be async or sync?
> And what will happen if I remove additivity="false"?
>
> Thank you.
> Best Regards,
> Dylan Su
>