Kaj Bjurman created LOG4J2-918:
----------------------------------
Summary: Combining Root and AsyncRoot in Xml configuration
Key: LOG4J2-918
URL: https://issues.apache.org/jira/browse/LOG4J2-918
Project: Log4j 2
Issue Type: Bug
Affects Versions: 2.1
Reporter: Kaj Bjurman
Priority: Minor
Don't know if this is a documentation issue, a configuration bug, or just a
user error, so I have left many fields empty in this report.
I'm trying to create an xml configuration where I have asynchronous logging to
a socket, and synchronous logging to disk.
The pdf-documentation says:
http://logging.apache.org/log4j/2.x/log4j-users-guide.pdf
"Synchronous and asynchronous loggers can be combined in configuration. This
gives you more
flexibility at the cost of a slight loss in performance (compared to making all
loggers asynchronous).
Use the <asyncRoot> or <asyncLogger> configuration elements to specify the
loggers that need to
be asynchronous. The same configuration file can also contain <root> and
<logger> elements for
the synchronous loggers."
.. so I created a configuration file that looks like this:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="trace">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level
%logger{36} - %msg%n" />
</Console>
<Socket name="Socket" host="localhost" port="666"
immediateFail="false" immediateFlush="true" reconnectionDelayMillis="5000">
<SerializedLayout />
</Socket>
</Appenders>
<Loggers>
<Root level="debug" includeLocation="false">
<AppenderRef ref="Console" />
</Root>
<AsyncRoot level="debug" includeLocation="false">
<AppenderRef ref="Socket"/>
</AsyncRoot>
</Loggers>
</Configuration>
{code}
That configuration only leads to logging to the socket appender, and nothing to
the console.
Changing the order of the root elements to:
{code}
<Loggers>
<AsyncRoot level="debug" includeLocation="false">
<AppenderRef ref="Socket"/>
</AsyncRoot>
<Root level="debug" includeLocation="false">
<AppenderRef ref="Console" />
</Root>
</Loggers>
{code}
Gives console logging, but no logging to the socket.
Changing the config to:
{code}
<Loggers>
<AsyncRoot level="debug" includeLocation="false">
<AppenderRef ref="Socket"/>
</AsyncRoot>
<Logger name="com" level="debug" includeLocation="false">
<AppenderRef ref="Console" />
</Logger>
</Loggers>
{code}
Gives both console and socket logging, for "com" and descendants, but code that
is logging to another domain than com does not end up in the console.
I also tried to leave the name empty in the test above, but that doesn't work.
What's the problem? The documentation, or my understanding of it, or the
implementation?
I would really like to have both asynchronous and synchronous root in the same
configuration.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]