Debug Logging using Console in High Sierra

Hey all,

I’m running OS X High Sierra and the console app has become a real pain in the backside. I am having problems using it to do any sort of decent debug logging. Yes, I can filter for my app name, but there is now a TON of stuff showing up that is OS related or must be to my app. Here’s an example:

debug	09:41:55.511832 -0500	MediaSwitcher	Bundle: <private>, key: Err306, value: There was a problem communicating with the web proxy server (HTTP)., table: Localizable, localizationName: (null), result: There was a problem communicating with the web proxy server (HTTP).
debug	09:41:55.511882 -0500	MediaSwitcher	Bundle: <private>, key: Please check your proxy settings. For help with this problem, contact your system administrator., value: Please check your proxy settings. For help with this problem, contact your system administrator., table: Localizable, localizationName: (null), result: Please check your proxy settings. For help with this problem, contact your system administrator.
info	09:41:55.511892 -0500	MediaSwitcher	nw_endpoint_flow_protocol_disconnected [3.1 75.146.116.250:80 cancelled socket-flow (null)] Output protocol disconnected
debug	09:41:55.511921 -0500	MediaSwitcher	Bundle: <private>, key: Err310, value: There was a problem communicating with the secure web proxy server (HTTPS)., table: Localizable, localizationName: (null), result: There was a problem communicating with the secure web proxy server (HTTPS).

None of that is mine. And I have no idea what web proxy server it says I am trying to use, etc. There is so much junk like this that just rolls through and I am having a hard time finding my System.Debuglog statements in it. Console never used to be like this.

Is there a way to shut all the rest of this stuff off?

Use the terminal and filter for your app name, only e.g.

tail -f /var/log/system.log | grep MyAppName

[quote=383557:@Thomas Eckert]Use the terminal and filter for your app name, only e.g.

tail -f /var/log/system.log | grep MyAppName

You’re better off using log stream --process MyAppName. It’s going to be much more efficient and the --predicate option can be used to help filter the data further.

[quote=383557:@Thomas Eckert]Use the terminal and filter for your app name, only e.g.

tail -f /var/log/system.log | grep MyAppName

This does not seem to work. Not seeing anything… :frowning:

I stopped using the console log a long long time ago (like 5 minutes after I first tried it)
today I have a “debug” method that I drop into my programs when required…
its not pretty, but then it has a temporary job to do

it streams the messages to a file on my desktop… no filtering… and its actually FASTER than the console log

Public Sub debug(msg As String,force as Boolean=false)
  //return
  Dim f As FolderItem
  Dim t As TextOutputStream
  f=get_Folder_Root.child("rapid.trace_log")
  If msg="!!!" Then
    If f.exists Then f.delete
    Exit Sub
  End If
  //
  #If DebugBuild Then
    force=True
  #EndIf
  
  If force Then 
    If Not f.exists Then
      t=TextOutputStream.Create(f)
    Else
      t=TextOutputStream.Append(f)
    End If
    t.write Str(Ticks)+":"+msg+EndOfLine
    t.close
  End If
End Sub

usage : DEBUG “your messsage”

This does work. There’s still tons of crap in there though that I don’t want but maybe I can filter it…

It’s sad but Windows does a better job with DebugView of filtering your data…

This will get you what you want:

sudo log stream --style compact  --predicate 'senderImagePath ENDSWITH "XojoFramework"' --process MyAppName

I’ve had luck switching the Console.App setting to the System.log messages and filtering on my app name.

how did you do that??

the simple method I posted above removes all those issues, is faster, allows each app to create its own log,

already start using this… added code to have a log file one a day and in the update, instead of just showing tick, i have sqldatetime in front.

by the way, what is tick for?

http://developer.xojo.com/ticks

i think i use tick before… to count how long a process take… have a start value and end value and calc the difference

In the code I posted, it is used to give a reference to how long it was between messages (in 1/60th of a second]

(From memory): Open Console.app, make the sidebar visible (Show Source), click System.Log, and then enter a search term in the search field. It helps if the search term is unique, such as “MyApp”. Test that it works. A small “Save” button will appear and you can save this filter on the toolbar.

Edit: I think you have to use System.DebugLog(msg) to get it to show up.

Possibly related question: In a Xojo app using a HTMLViewer, is there a way for console.warning or console.error messages inside the HTML/Javascript content of that HTMLViewer to be displayed?