/**
  * Set the file trace level.
  *
  * @param level the new level
  */
 public void setLevelFile(int level) {
   if (level == ADAPTER) {
     String adapterClass = "org.h2.message.TraceWriterAdapter";
     try {
       writer = (TraceWriter) Class.forName(adapterClass).newInstance();
     } catch (Throwable e) {
       e = DbException.get(ErrorCode.CLASS_NOT_FOUND_1, e, adapterClass);
       write(ERROR, Trace.DATABASE, adapterClass, e);
       return;
     }
     String name = fileName;
     if (name != null) {
       if (name.endsWith(Constants.SUFFIX_TRACE_FILE)) {
         name = name.substring(0, name.length() - Constants.SUFFIX_TRACE_FILE.length());
       }
       int idx = Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\'));
       if (idx >= 0) {
         name = name.substring(idx + 1);
       }
       writer.setName(name);
     }
   }
   levelFile = level;
   updateLevel();
 }
 private void logWritingError(Exception e) {
   if (writingErrorLogged) {
     return;
   }
   writingErrorLogged = true;
   Exception se = DbException.get(ErrorCode.TRACE_FILE_ERROR_2, e, fileName, e.toString());
   // print this error only once
   fileName = null;
   sysOut.println(se);
   se.printStackTrace();
 }