title: How to store Logs in a txt file using the android.util.log
body: <p>I know this topic has been talked a lot but not in this meanings. 
  I need to store the logs in a .txt file but I cannot use the log4j or any other class but android.util.log
  I have this solution but it is not the best. 
  For have the same information than in:         Log.i(TAG, "An INFO Message");
  I have to write... </p>
  
  <pre><code>ERROR = logLevel &lt; 3;
  WARNING = logLevel &lt; 2;
  INFO = logLevel &lt; 1;
  if (INFO){ 
  
      appendLog("LEVEL: I    TIME: "+java.util.GregorianCalendar.DAY_OF_MONTH +
                          "-"+ java.util.GregorianCalendar.MONTH +" "+GregorianCalendar.HOUR_OF_DAY +":"+GregorianCalendar.MINUTE +
                          ":"+GregorianCalendar.SECOND +"."+GregorianCalendar.MILLISECOND + "    PID: "+
                          android.os.Process.myPid()+ "    TID: "+android.os.Process.myTid()+ "    Application: com.example.myapplication"+
                          "    TAG:" +TAG+ "    TEXT: An INFO Message");
  }
  </code></pre>
  
  <p>and then...</p>
  
  <pre><code>public void appendLog(String text) {        
      File logFile = new File("sdcard/log.txt"); 
      if (!logFile.exists()) { 
          try { 
              logFile.createNewFile(); 
          }catch (IOException e){ 
              e.printStackTrace(); 
        } 
     } 
     try { 
         BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));  
         buf.append(text); 
         buf.newLine(); 
         buf.close(); 
     } catch (IOException e) { 
         e.printStackTrace(); 
     } 
  }
  </code></pre>
  
  <p>Does anyone has a more elegant solution than this? Thank you for helping me.</p>