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

Gary Gregory edited comment on LOG4J2-911 at 12/2/14 1:20 AM:
--------------------------------------------------------------

The current code in 
{{org.apache.logging.log4j.core.config.FileConfigurationMonitor}} only reloads 
when if the config file has changed (not the fragments). 

What you see ATM is consistent with that.

(1) It sounds like we could some additional smarts to detect if XInclude is 
used and if any of those files have changed. 

(2) Otherwise, it does not seem like having a toggle to always reload the 
config even if the main file has not changed is a nice thing to do. 

(3) A third way would be to have the toggle to always reload but then compare 
the DOM or Log4j object model to see if it is the same as what was last loaded.

So really (1) or (3) are reasonable but not trivial.



was (Author: garydgregory):
The current code in 
{{org.apache.logging.log4j.core.config.FileConfigurationMonitor}} only reloads 
when if the config file has changed. 

What you see ATM is consistent with that.

(1) It sounds like we could some additional smarts to detect if XInclude is 
used and if any of those files have changed. 

(2) Otherwise, it does not seem like having a toggle to always reload the 
config even if the main file has not changed is a nice thing to do. 

(3) A third way would be to have the toggle to always reload but then compare 
the DOM or Log4j object model to see if it is the same as what was last loaded.

So really (1) or (3) are reasonable but not trivial.


> 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-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org

Reply via email to