B4J Question [Solved] best way to save DebugLog?

mw71

Active Member
Licensed User
Longtime User
what is the best Way to save the Debug Log in File, if the user it switch on (i will it enabel/disable with a switch)?
my idea is to call a sub instead of Log(...)
B4X:
Sub WriteLogToFile(txt As String)
    Log(txt)
    Dim txtWriter As TextWriter
    txtWriter.Initialize(File.OpenOutput(File.DirData("MyApp"),"Logfile.txt",True))
    txtWriter.WriteLine(txt)
    txtWriter.Close
End Sub

Is this the best way or is there a better way?
 

Dadaista

Active Member
Licensed User
Longtime User
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Also,

If NOT(production) then
RedirectOutput...
End if

' when developing - dont enable it. This way your logs tab will show everything in debug and release...
(where production is a global public boolean var)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…