How to generate external logfile in android app? -


Do I know there is any way to generate an external log file?

This can be done for example with Java.util.logging classes:

  import android.os.Environment; Import android.util.log; Import java.util.logging.FileHandler; Import java.util.logging.Level; Import java.util.logging.LogRecord; Import java.util.logging.SimpleFormatter; File handler fh = faucet; String name; If (0 == Environmental Gatestylestoristestat ()) Compare (environment. MIDAImautage) name = Environment. GatexAnationalized Directory (). GetAbsolutePath (); Other Name = Environment GateData Directory () GetAbsolutePath (); Name + = "/mylogfile.log"; {FH = try new file handler (name, 256 * 1024, 1, true); Fh.setFormatter (new SimpleFormatter ()); Fh.publish (new log record (level, tag + ":" + msg)); } Hold (exception e) {Log.e ("MyLog", "FileHandler Exception", e); Return; } Finally {if (fh! = Null) fh.close (); }  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -