You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2015/07/05 07:04:04 UTC
[jira] [Resolved] (LOG4J2-918) Combining Root and AsyncRoot in Xml
configuration
[ https://issues.apache.org/jira/browse/LOG4J2-918?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Remko Popma resolved LOG4J2-918.
--------------------------------
Resolution: Fixed
Fix Version/s: 2.4
Clarified docs. Committed to Git in 8d4dc1f28c062d968b2fc6b4432cb6d5d3d4f490. Please verify and close.
> 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
> Assignee: Remko Popma
> Priority: Minor
> Fix For: 2.4
>
>
> 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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org