anchor.diff:      end,
       ets:insert(?MODULE, {level, Level}),
   
  -    case file:open(Filename, [append]) of
  -    {ok, Fd} ->
  -        {ok, #state{fd = Fd, level = Level, sasl = Sasl}};
  -    {error, eacces} ->
  -        {stop, {file_permission_error, Filename}};
  +    DiskLogOptions = [
  +        {file, Filename}, {name, ?DISK_LOGGER},
  +        {format, external}, {type, halt}, {notify, true}
  +    ],
  +    case disk_log:open(DiskLogOptions) of
  +    {ok, ?DISK_LOGGER} ->
  +        {ok, #state{level = Level, sasl = Sasl}};
       Error ->
           {stop, Error}
       end.
  
positive.code: -define(LEVEL_INFO, 2).
  -define(LEVEL_DEBUG, 1).
  
  -record(state, {
      fd,
      level,
      sasl
  }).
  
  debug(Format, Args) ->
      {ConsoleMsg, FileMsg} = get_log_messages(self(), debug, Format, Args),
      gen_event:sync_notify(error_logger, {couch_debug, ConsoleMsg, FileMsg}).
  
  info(Format, Args) ->
      {ConsoleMsg, FileMsg} = get_log_messages(self(), info, Format, Args),
      gen_event:sync_notify(error_logger, {couch_info, ConsoleMsg, FileMsg}).
  
  error(Format, Args) ->
      {ConsoleMsg, FileMsg} = get_log_messages(self(), error, Format, Args),
      gen_event:sync_notify(error_logger, {couch_error, ConsoleMsg, FileMsg}).
  
  
  level_integer(error)    -> ?LEVEL_ERROR;
  
negative.code:     ets:insert(?MODULE, {level, NewLevel}),
      {ok, ok, State#state{level = NewLevel}}.
  
  handle_info({disk_log, _Node, _Log, {error_status, Status}}, _State) ->
      io:format("Disk logger error: ~p~n", [Status]),
      % couch_event_sup will restart us.
      remove_handler;
  handle_info(_Info, State) ->
      {ok, State}.
  
  code_change(_OldVsn, State, _Extra) ->
      {ok, State}.
  
  terminate(_Arg, _State) ->
      ok = disk_log:close(?DISK_LOGGER).
  
  get_log_messages(Pid, Level, Format, Args) ->
      ConsoleMsg = unicode:characters_to_binary(io_lib:format(
  