You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Ralph Goers (Jira)" <ji...@apache.org> on 2021/06/23 20:22:00 UTC

[jira] [Commented] (LOG4J2-3112) Repeated FileNotFoundException from ConfiguratonFileWatcher if log4j config file was deleted

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

Ralph Goers commented on LOG4J2-3112:
-------------------------------------

Why would you expect it to happen only once? The app was configured to watch for changes in the file. It would be incorrect behavior to stop monitoring the file. Just because the file was deleted on one interval doesn't mean a new one won't be provided in the next interval and a reconfiguration would be required. 

You are correct that we don't need the stack trace over and over again but something should be logged. This would apply to other exceptions as well such as the permissions being changed and the app no longer has read access to the file.

> Repeated FileNotFoundException from ConfiguratonFileWatcher if log4j config file was deleted
> --------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3112
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3112
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: 2.13.3, 2.14.1
>            Reporter: Andrey Turbanov
>            Priority: Minor
>
> I found a bit unexpected behavior with {{ConfiguratonFileWatcher}} when configuration file was deleted.
> It repeatedly prints {{FileNotFoundException}} each monitoringInterval.
> I've prepared repository to demonstrate bug - https://github.com/turbanoff/log4j-watcher-delete. Just run Run Configuration "Main" in IDEA and then delete file {{log4j2.xml}}
> {noformat}
> Sleep a bit
> Sleep a bit
> Sleep a bit
> Sleep a bit
> Sleep a bit
> 2021-06-23 21:15:34,800 Log4j2-TF-1-ConfiguratonFileWatcher-2 ERROR Cannot locate file F:\Projects\log4j-watcher-delete\log4j2.xml java.io.FileNotFoundException: log4j2.xml (Не удается найти указанный файл)
> 	at java.base/java.io.FileInputStream.open0(Native Method)
> 	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
> 	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
> 	at org.apache.logging.log4j.core.config.ConfigurationSource.resetInputStream(ConfigurationSource.java:283)
> 	at org.apache.logging.log4j.core.config.xml.XmlConfiguration.reconfigure(XmlConfiguration.java:268)
> 	at org.apache.logging.log4j.core.LoggerContext.onChange(LoggerContext.java:761)
> 	at org.apache.logging.log4j.core.util.AbstractWatcher$ReconfigurationRunnable.run(AbstractWatcher.java:93)
> 	at java.base/java.lang.Thread.run(Thread.java:829)
> Sleep a bit
> Sleep a bit
> 2021-06-23 21:15:38,806 Log4j2-TF-1-ConfiguratonFileWatcher-3 ERROR Cannot locate file F:\Projects\log4j-watcher-delete\log4j2.xml java.io.FileNotFoundException: log4j2.xml (Не удается найти указанный файл)
> 	at java.base/java.io.FileInputStream.open0(Native Method)
> 	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
> 	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
> 	at org.apache.logging.log4j.core.config.ConfigurationSource.resetInputStream(ConfigurationSource.java:283)
> 	at org.apache.logging.log4j.core.config.xml.XmlConfiguration.reconfigure(XmlConfiguration.java:268)
> 	at org.apache.logging.log4j.core.LoggerContext.onChange(LoggerContext.java:761)
> 	at org.apache.logging.log4j.core.util.AbstractWatcher$ReconfigurationRunnable.run(AbstractWatcher.java:93)
> 	at java.base/java.lang.Thread.run(Thread.java:829)
> Sleep a bit
> Sleep a bit
> 2021-06-23 21:15:42,810 Log4j2-TF-1-ConfiguratonFileWatcher-4 ERROR Cannot locate file F:\Projects\log4j-watcher-delete\log4j2.xml java.io.FileNotFoundException: log4j2.xml (Не удается найти указанный файл)
> 	at java.base/java.io.FileInputStream.open0(Native Method)
> 	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
> 	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
> 	at org.apache.logging.log4j.core.config.ConfigurationSource.resetInputStream(ConfigurationSource.java:283)
> 	at org.apache.logging.log4j.core.config.xml.XmlConfiguration.reconfigure(XmlConfiguration.java:268)
> 	at org.apache.logging.log4j.core.LoggerContext.onChange(LoggerContext.java:761)
> 	at org.apache.logging.log4j.core.util.AbstractWatcher$ReconfigurationRunnable.run(AbstractWatcher.java:93)
> 	at java.base/java.lang.Thread.run(Thread.java:829)
> {noformat}
> I would expect that exception logging happen only once.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)