logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LOG4J2-911) monitorInterval is not honored when using XInclude
Date Tue, 02 Dec 2014 03:21:12 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14230913#comment-14230913
] 

Remko Popma edited comment on LOG4J2-911 at 12/2/14 3:20 AM:
-------------------------------------------------------------

In addition to what Gary said, our current XML parsing logic is not aware of which elements
are in the configuration file and which elements are XIncluded. I'm not sure if it is even
possible to make this distinction, as far as I can see the XInclude logic is all internal
to the DOM parser and not exposed to the Document consumer.

I also agree with Gary that, even if it _were_ possible to find out which document sections
were XIncluded, the logic to detect if a fragment was modified would be quite complex.

May I suggest a workaround? Is it possible for your application to "touch" the log4j2.xml
configuration file (change its {{lastModified()}} time) whenever an included fragment has
changed? This would then trigger the reconfiguration as desired.


was (Author: remkop@yahoo.com):
In addition to what Gary said, our current XML parsing logic is not aware of which elements
are in the configuration file and which elements are XIncluded. I'm not sure if it is even
possible to make this distinction, as far as I can see the XInclude logic is all internal
to the DOM parser and not exposed to the Document consumer.

I also agree with Gary that, even if it _were_ possible to find out which document sections
were XIncluded, the logic to detect if a fragment was modified would be quite complex.

May I suggest a workaround? Is it possible for your application to "touch" the log4j2.xml
configuration file whenever an included fragment has changed? This would then trigger the
reconfiguration as desired.

> monitorInterval is not honored when using XInclude
> --------------------------------------------------
>
>                 Key: LOG4J2-911
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-911
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators
>    Affects Versions: 2.1
>         Environment: Windows, Linux
>            Reporter: Edwin F. López
>            Priority: Critical
>
> Hi there.
> I'm using Log4J2 version 2.1 and while doing a proof of concept for centralizing my configurations,
I have stumble upon the following scenario:
> I have created a configuration file which uses monitorInterval=15 seconds in a console
application. For loading the appenders and loggers, I have used the XInclude directive to
reference the external source information, however, I'm using a servlet to generate the xml
instead of local files. This servlet runs fine and prints the xml fragments correctly.
> Well, it happens that the configuration only reloads when the log4j2.xml file changes,
however, if there is any change in the output from the servlet, it doesn't reload the new
configuration. In other words, I was expecting that the configuration was getting reloaded
every 15 seconds, so it could take the new values from the servlet, but it is not happening.
> I have activated the statuslogger to a level=trace, and it effectively registers the
reload when manually modifying the log4j2.xml, but it never shows anything when the xinclude
values changes.
> Is this the expected behavior? I was expecting a reconfiguration every 15 secs.
> See below the log4j2.xml and appenders.xml and loggers.xml
> Log4J2 config file:
> {code:xml}
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <Configuration
>     xmlns:xi="http://www.w3.org/2001/XInclude"
>     name="Log4J2Config"
>     monitorInterval="10"
>     status="Trace">
>     <Properties>
>         <Property name="Pattern">%d{ISO8601}|APP=%marker|%p|%c|%M|%m%n</Property>
>     </Properties>
>     <!-- Appenders -->
>     <xi:include href="http://localhost:7001/log4j2config/getlog4j2xmlconfig?appCode=log4jConfig&amp;section=appenders"
/>
>     <!-- Loggers -->
>     <xi:include href="http://localhost:7001/log4j2config/getlog4j2xmlconfig?appCode=log4jConfig&amp;section=loggers"
/>
> </Configuration>
> {code}
> Appenders fragment:
> {code:xml}
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <Appenders>
>     <Console name="Console" target="SYSTEM_ERR">
>         <PatternLayout pattern="${Pattern}"/>
>     </Console>
>     <RollingFile
>         name="RollingFile"
>         fileName="app.log"
>         filePattern="app-%d{yyyyMMdd}-%i.log.gz">
>         <PatternLayout pattern="${Pattern}" />
>         <Policies>
>             <SizeBasedTriggeringPolicy size="1MB" />
>         </Policies>
>     </RollingFile>
> </Appenders>
> {code}
> Loggers fragment:
> {code:xml}
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <Loggers>
>     <Root level="Off">
>         <AppenderRef ref="Console" />
>     </Root>
>     <Logger name="log4jconfig.Log4JConfig" level="FATAL" includeLocation="true">
>         <AppenderRef ref="RollingFile" />
>     </Logger>
> </Loggers>
> {code}
> Thanks a lot



--
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


Mime
View raw message