-
1. Re: Log4J Failed to rename [logs/CacheClearance.log] to [logs/CacheClearance.log.2017-08-31].
jaikiran Sep 4, 2017 12:42 AM (in response to gir489)Can you paste the entire exception stacktrace? Which exact version of WildFly 10 is this?
-
2. Re: Log4J Failed to rename [logs/CacheClearance.log] to [logs/CacheClearance.log.2017-08-31].
jaikiran Sep 4, 2017 12:47 AM (in response to gir489)As to figuring out what is exactly holding locks on the file, maybe this tool will help https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer
-
3. Re: Log4J Failed to rename [logs/CacheClearance.log] to [logs/CacheClearance.log.2017-08-31].
gir489 Sep 5, 2017 9:09 AM (in response to jaikiran)There is no stack track. The error Failed to rename [logs/CacheClearance.log] to [logs/CacheClearance.log.2017-08-31] is all I get in the console.
This is most likely due to the fact that this.closeFile() doesn't throw an exception, and file.renameTo just returns true or file:
this.closeFile(); File target = new File(this.scheduledFilename); if (target.exists()) { target.delete(); } File file = new File(this.fileName); boolean result = file.renameTo(target); if (result) { LogLog.debug(this.fileName + " -> " + this.scheduledFilename); } else { LogLog.error("Failed to rename [" + this.fileName + "] to [" + this.scheduledFilename + "]."); }
That's from DailyRollingFileAppender.class.
I've already determined that java.exe was holding a lock on it by stepping through the log code, and finding that once Log.info was called from ClearCache.java, the file was locked. However, I used handle.exe (which is just the command line version of process explorer) to find that java.exe was indeed the only EXE with a handle to the log.
I'm on Wildfly 10.1.0.
-
4. Re: Log4J Failed to rename [logs/CacheClearance.log] to [logs/CacheClearance.log.2017-08-31].
gir489 Sep 5, 2017 10:08 AM (in response to gir489)I figured it out. We were compartmentalizing multiple Logger repositories (which the Log4J spec says is for internal use only), and I don't even know how this was working on JBoss 4...
Fixed by just calling Logger.getLogger(category) instead of trying to do Log4J's job ourselves.