B4J Question [ABMaterial] how to minimize log file?

rbirago

Active Member
Licensed User
Longtime User
In the ABMaterial sample Pages there are lots of logs...and this is good, because in this way the developer can follow the steps of the users. After this initial monitor, when the application has many users it is more advisable to set some different degrees of log (i.e. all, only significant, only very important, etc.) to better focus the level of information.
To achieve this it is not so difficult, using a centralized function instead of the log command...but some log lines are implicit:
B4X:
Waiting for value (2 ms)
Waiting for value (0 ms)
Waiting for value (2 ms)
UpdateFromCache: PageSearchc53ca41b-184c-4a0b-84e3-fc25c8351c71
Saving the first instance
Waiting for value (2 ms)
Waiting for value (14 ms)
Waiting for value (23 ms)
Waiting for value (1 ms)
Waiting for value (0 ms)
Waiting for value (1 ms)
UpdateFromCache: PageAdmc53ca41b-184c-4a0b-84e3-fc25c8351c71
Saving the first instance
Waiting for value (1 ms)
Waiting for value (5 ms)
Waiting for value (1 ms)
Waiting for value (2 ms)
Waiting for value (10 ms)
Waiting for value (4 ms)
How to manage/hinibit these kind of standard logs in ABMaterial?
Thanks
Roberto
 

alwaysbusy

Expert
Licensed User
Longtime User
This looks like it runs in debug mode (the Waiting for value lines). They should not be there in Release mode as this is jServer simulating delays to be more realistic in debug mode.

I also use a .log file per day using:

B4X:
Sub AppStart (Args() As String)    
    #If RELEASE        
        HandleLogs
    #end if
    ...
End Sub

Sub HandleLogs
    Dim CurrentDay As Long = 0
    Do While True
        Dim year As Int = DateTime.GetYear(DateTime.Now)
        Dim month As Int = DateTime.GetMonth(DateTime.Now)
        Dim day As Int = DateTime.GetDayOfMonth(DateTime.Now)
        Dim d As Long = DateUtils.SetDate(year, month, day)
        If d <> CurrentDay Then
            CurrentDay = d
            RedirectOutput(File.DirApp, "Work2020_logs" & ABMShared.Date2StringSafe(DateTime.now, False) & ".log")            
        End If
        Sleep(60000)
    Loop
End Sub

Sub RedirectOutput (Dir As String, FileName As String)
#if RELEASE
   If LogsOutput.IsInitialized Then LogsOutput.Close
   LogsOutput = File.OpenOutput(Dir, FileName, True) 'Set to True to append the logs
   Log("Redirecting logs to: " & FileName)
   Dim ps As JavaObject
   ps.InitializeNewInstance("java.io.PrintStream", Array(LogsOutput, True, "utf8"))
   Dim jo As JavaObject
   jo.InitializeStatic("java.lang.System")
   jo.RunMethod("setOut", Array(ps))
   jo.RunMethod("setErr", Array(ps))
#end if
End Sub

Alwaysbusy
 
Upvote 0

rbirago

Active Member
Licensed User
Longtime User
no, the waiting for value... and the other lines are logged also in release mode. Any suggestion?
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
The other lines (like UpdateFromCache: PageSearchc53ca41b-184c-4a0b-84e3-fc25c8351c71) will be in release mode, as they are indeed from ABMaterial. They can not be disabled.

But the waiting for value should not as they are from B4Js jServer library and I have never seen them in my logs when I compiled in Release mode. I just checked my logs again from our production server and there are zero 'waiting for value' lines in it. You should indeed try to find why they are in yours when you compile in Release mode , because that means your app is running way slower than it can be because of these 'simulated' delays.
 
Upvote 0

rbirago

Active Member
Licensed User
Longtime User
that's the trick! adding
B4X:
Server.LogWaitingMessages = False
the waiting logs disappear, also in debug mode.
It is strange, because the app is based on the ABMaterial templates classes and pages and I have not added any instruction for the class Server....
Thank you for the answer.
Roberto
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
that's the trick! adding
B4X:
Server.LogWaitingMessages = False
the waiting logs disappear, also in debug mode.
It is strange, because the app is based on the ABMaterial templates classes and pages and I have not added any instruction for the class Server....
Thank you for the answer.
Roberto
Server.LogWaitingMessages = False ---- That tripped me up too, some time ago... Live and learn....
 
Upvote 0
Top