B4i Library iReleaseLogger - Read the logs in release mode

iReleaseLogger combined with the desktop B4iLogger tool (written with B4J) allow you to monitor the app logs in release mode. This is useful when you encounter an error that you are unable to reproduce in debug mode.

The release logger sends udp messages which the desktop logger prints.
Depending on your firewall settings you may see a dialog such as this one when you first run the logger:

SS-2015-02-25_17.30.25.png


You can also manually add an incoming rule for UDP connections on port 54323.

In order to activate the logger you need to:
1. Add a reference to iReleaseLogger and iNetwork libraries.
2. Add this code to your app (with the desktop ip address):
B4X:
Private Sub Application_Start (Nav As NavigationController)
Dim rl As ReleaseLogger
rl.Initialize("192.168.0.6", 54323)

Run the desktop tool with:
B4X:
java -jar B4iLogger.jar

Notes

- The logs in release mode do not include all the information that is available in debug mode.
- Do not try to upload your app with iReleaseLogger library included to the App Store. It will be rejected.
- You can keep the desktop tool running for as long as needed.


In case you are interested, the B4J code is:
B4X:
Sub Process_Globals
   Private usock As UDPSocket
End Sub

Sub AppStart (Args() As String)
   Dim port As Int = 54323
   Dim serv As ServerSocket 'ignore
   usock.Initialize("usock", port, 16000)
   Log($"My IP Address ${serv.GetMyIP}"$)
   Log($"Waiting on port ${port}"$)
   StartMessageLoop
End Sub

Sub usock_PacketArrived (Packet As UDPPacket)
   Log(BytesToString(Packet.Data, 0, Packet.Length, "UTF8"))
End Sub
It should be trivial to create a similar logging monitor in B4A or B4i (to read the logs on a different device).
 

Attachments

  • iReleaseLogger.zip
    13 KB · Views: 304
  • B4iLogger.jar
    90.9 KB · Views: 418
Last edited:

Shay

Well-Known Member
Licensed User
Longtime User
Thanks for this, but since no more TestFlight, this can work only on my local phone
if some tester has different phone with issue, how can I send him IPA so he can replicate his issue?
 

yonson

Active Member
Licensed User
Longtime User
Hi Erel

great feature however I'm getting this error when running this :-

C:\work\B4i>java -jar B4iLogger.jar
main._appstart (java line: 48)
java.net.BindException: Address already in use: Cannot bind
at java.net.DualStackPlainDatagramSocketImpl.socketBind(Native Method)
at java.net.DualStackPlainDatagramSocketImpl.bind0(Unknown Source)
at java.net.AbstractPlainDatagramSocketImpl.bind(Unknown Source)
at java.net.DatagramSocket.bind(Unknown Source)
at java.net.DatagramSocket.<init>(Unknown Source)
at java.net.DatagramSocket.<init>(Unknown Source)
at java.net.DatagramSocket.<init>(Unknown Source)
at anywheresoftware.b4a.objects.SocketWrapper$UDPSocket.Initialize(Socke
tWrapper.java:345)
at b4j.example.main._appstart(main.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)


I've checked on netstat and nothing is showing up on this port. Any thoughts?
THanks
John
 

yonson

Active Member
Licensed User
Longtime User
just to help anyone who finds that port is already in use, the fix to kill whatever is on that port is :-

1) view all port activity : netstat -a -n -o
2) record the PID for the particular port in question (in my case UDP so 0:0:0:0:54323)
3) goto task manager - > Details -> sort by PID
4) find the rogue PID process and kill it.
 

stanmiller

Active Member
Licensed User
Longtime User
Instead of opening a command window and starting manually, I double clicked on B4iLogger.jar and it started running in the background detached from a console.

I killed the java process with this command.

c:\> wmic process where "name like '%java%'" delete

Then opened a command window and started as advised:

java -jar B4iLogger.jar

The console remained opened and I could see log output.
 

stanmiller

Active Member
Licensed User
Longtime User
iReleaseLogger combined with the desktop B4iLogger tool (written with B4J) allow you to monitor the app logs in release mode. This is useful when you encounter an error that you are unable to reproduce in debug mode.

The release logger sends udp messages which the desktop logger prints.

Thanks for this tool!

As a sanity check between the app and B4iLogger.jar could you send a startup packet like "-- iRelease Logger v1.0 -- " to the desktop logger when the object is initialized?

Because the logger is using UDP, the packets could be blocked or tossed aside and you would never know.

I couldn't tell if iReleaseLogger was communicating with the desktop until I received a "Can't find keyplane that supports type 8..." message. That's the only message I saw during testing - so it looks like I'm good.
 

JackKirk

Well-Known Member
Licensed User
Longtime User
I have been quite happily B4iLogging away - until today.

My PC has a static local IP address on the router of 192.168.1.6

Up until today that is the address that B4iLogger was displaying.

Now B4iLogger is displaying 169.254.88.26

Router still says it is on 192.168.1.6

All other devices on router (printer, NAS, Samsung S5, iPhone 5, laptop) are showing correct addresses.

I have turned everything, including router, off/on - no effect, B4iLogger still showing 169....

I used the 169... address in a test app:

Dim rl As ReleaseLogger
rl.Initialize("169.254.88.26", 54323)

But it doesn't log to B4iLogger showing that IP

I tried correct 192... address of PC - can't log to that either.

I am out of options - hence this call for help.
 

JackKirk

Well-Known Member
Licensed User
Longtime User
The ip address displayed is not really important. It can show the wrong one if there are multiple ips available. Use the correct one.
Maybe this should be spelt out somewhere where a B4iLogger user will see it - say in its initial blurt - or can it spit out all possibilities?
Make sure that the port is open in your firewall. Are you able to run the app in debug mode?
Yes - able to run in debug mode.

I worked out what I was doing wrong - when the 169... stuff started coming out of B4iLogger I managed to confuse myself and ended up actually using the ip address of the iPhone not the ip address of the PC in the apps rl.Initialize("... statement.

Is there an emoticon for banging head against wall...
 

Sandman

Expert
Licensed User
Longtime User
I just wanted to add that netcat also can receive the logs using this command:

B4X:
nc -l -u -p 54323

Short description of what this does:
  • nc (that's what netcat is called)
  • -l = listen for incoming connections
  • -u = use udp
  • -p = use this port

(This means that you don't need B4iLogger.jar if you do it like this.)
 
Last edited:
Top