]
Ondrej Zizka updated JBLOGGING-55:
----------------------------------
Attachment: log4j.xml
NPE in FileAppender$Helper
--------------------------
Key: JBLOGGING-55
URL:
https://issues.jboss.org/browse/JBLOGGING-55
Project: JBoss Logging
Issue Type: Bug
Security Level: Public(Everyone can see)
Reporter: Ondrej Zizka
Assignee: David Lloyd
Attachments: log4j.xml
When you set the file="..." to just a file, i.e. file="foobar.log",
then you get a NPE at line
if (!dir.exists()) {
probably because
dir = new File(filename.trim()).getParentFile();
returns null.
I'd expect the appender to write to a file in new File( new
File(System.getProperty("user.dir")), filename.trim() ).
package org.jboss.logging.appender;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.log4j.helpers.LogLog;
public class FileAppender$Helper
{
public static void makePath(String filename)
{
File dir;
try
{
URL url = new URL(filename.trim());
dir = new File(url.getFile()).getParentFile();
}
catch (MalformedURLException e) {
dir = new File(filename.trim()).getParentFile();
}
if (!dir.exists()) {
boolean success = dir.mkdirs();
if (!success)
LogLog.error("Failed to create directory structure: " + dir);
}
}
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: