Ok, so in a rare moment of sloth, I didn't go back and check the
javadocs on canRead() and missed the "IFF file exists" clause.
Looking a little closer, it would seem that the right fix would be for
avalon to throw an exception on
FileOutputLogTarget.setFilename(String).  Maybe velocity could do:

    public void init(String logFile)
        throws Exception
    {
        FileOutputLogTarget target = new FileOutputLogTarget();
        File logFileLocation = new File (logFile);

        try
        {
          // false if file exists
          if (!logFileLocation.createNewFile())
          {
            if (!(logFileLocation.exists() && logFileLocation.canRead()))
            {
              throw new Exception("Error initializing log file: " + logFile);
            }
          }
        }
        catch (IOException ioe)
        {
          throw new Exception("Error initializing log file (" +
                              logFile + ") " + ioe);
        }
        ...


Maybe not the best way.  Just trying to get some more informative
exceptions. 


-bl

Reply via email to