-
Notifications
You must be signed in to change notification settings - Fork 486
Open
Description
If the logName
is like xyx/a.log
and the xyz folder does not exist a FileNotFound exception is thrown and since the log file is not there it gets lost.
I have made a local code change to create the path directories
protected synchronized void openLogFile() throws IOException {
if (f != null) {
f.close();
}
Path filePath = Paths.get(logName);
if (!(filePath.toFile()
.exists())) {
// Ensure the parent directories exist
Files.createDirectories(filePath.getParent());
// Create the file if it does not exist
Files.createFile(filePath);
}
f = new FileOutputStream(filePath.toFile(), true);
setPrintStream (new PrintStream(f));
p.println ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
p.println ("<logger class=\"" + getClass().getName() + "\">");
}
And a unit test for my environment where the logger deploy has the appropriate prefix suffix
<log-listener class="org.jpos.util.DailyLogListener">
<property name="prefix" value="xyx/a" />
<property name="suffix" value=".log" />
<property name="window" value="86400" />
<property name="copies" value="90" />
<property name="maxsize" value="100000000" />
<property name="compression-format" value="none" />
<property name="rotate-on-startup" value="true" />
</log-listener>
public void initSwitchTest() throws InterruptedException, IOException {
Q2 q2 = new Q2("deploy");
q2.start();
Awaitility.await().atMost(10, SECONDS).until(q2::running);
Thread.sleep(5000);
q2.shutdown();
Assert.assertTrue(new File("xyx/a.log").exists());
}
Metadata
Metadata
Assignees
Labels
No labels