logback-android/src/main/java/ch/qos/logback/core/helpers/Transform.java
public static String escapeTags(final String input) {
    if (input == null || input.length() == 0 || !UNSAFE_XML_CHARS.matcher(input).find()) {
      return input;
    }

    StringBuffer buf = new StringBuffer(input);
    return escapeTags(buf);
  }
public static String escapeTags(final String input) {
    if (input == null || input.length() == 0 || !UNSAFE_XML_CHARS.matcher(input).find()) {
      return input;
    }

    StringBuffer buf = new StringBuffer(input);
    return escapeTags(buf);
  }
This method takes a string which may contain HTML tags (ie, &lt;b&gt;,
&lt;table&gt;, etc) and replaces any '&lt;','&gt;' ... characters with
respective predefined entity references.

@param input
The text to be converted.
@return the string with the tags escaped