code: public static void writeStackTraceFile(String filename, String deviceName){
          //  Get the stack to write it in a file
          StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
          for (StackTraceElement element : stackTrace) {
              System.out.println(element);
          }
          //  Get host name and pid
          String host = "";
          try {
              host = java.net.InetAddress.getLocalHost().getCanonicalHostName();
          } catch (final java.net.UnknownHostException e) { /* */  }
          int pid = DevLockManager.getInstance().getJvmPid();
          filename += "."+host+"."+pid;
          StringBuilder sb = new StringBuilder(deviceName+":\n");
          for (StackTraceElement stackTraceElement : stackTrace)
              sb.append(stackTraceElement).append('\n');
          writeFile(filename, sb.toString());
      }
docs: ===============================================================