# File httpd/lib/symbiosis/apache_logger.rb, line 152
  def open_log(log, opts={})
    begin
      #
      # Set a default uid/gid.
      #
      opts = {:uid => self.uid, :gid => self.gid}.merge(opts)

      #
      # Set up a couple of things before we open the file.  This will make
      # sure the ownerships are correct.
      #
      begin
        parent_dir = File.dirname(log)
        warn "#{$0}: Creating directory #{parent_dir}" if $VERBOSE
        Symbiosis::Utils.mkdir_p(parent_dir, :uid => opts[:uid], :gid => self.gid, :mode => 0755)
      rescue Errno::EEXIST
        # ignore
      end

      warn "#{$0}: Opening log file #{log}" if $VERBOSE
      filehandle = Symbiosis::Utils.safe_open(log, "a+", :mode => 0644, :uid => opts[:uid], :gid => opts[:gid])
      filehandle.sync = opts[:sync]

    rescue StandardError => err
      filehandle = nil
      warn "#{$0}: Caught #{err}" if $VERBOSE
    end
  
    filehandle
  end