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

Edwin F. López commented on LOG4J2-911:
---------------------------------------

Thank you very much Gary and Remko for your quick answers. I've considered what 
you suggested and what I'm trying to achive, which is having a central 
configuration repository for all my loggers wherever they are deployed, and I 
must say that I'm scratching a pretty edgy use case. In my particular case, I 
can't "touch" my config file since it is being obtained by the same servlet 
(surprise :-)), however it could work for other cases.

However, for the sake of completeness, I believe that the easy fix could be to 
go for Gary's option (2), and add a new attribute to the configuration element, 
something like "forceReload=true|false", so it would be the analyst's choice to 
enable it or not. 

Having said that, I also think this would bring so little gain and could open a 
can of worms (even the gates of hell). I believe that this incident can be 
closed as "won't fix", but should be documented in the site.

Instead of this, I'm opening a new feature request, to allow for loading the 
configuration from a centralized source, like a database or a webservice (soap 
or ReST) additional to the XMLConfiguration or JSONConfiguration already in 
place.

Again, thank you very much for your help, input and work.

> 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 stumbled 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to