Where is system.log() writing?

Has MacOS changed how it deals with something like:

system.Log(System.LogLevelNotice, “This is a test”)

I am currently running 10.14.6 and after my project runs that code I cannot find the message in any log.

If I open the Console app and select my Mac from the Devices list the messages do appear as my app runs… but if I quit Console and relaunch it they are gone… So it seems they are captured by Console but not saved anywhere.

Maybe I am nuts but it seems that these messages used to be saved into a log file that I could look back on.

I’ve only been able to locate them at under “Messages” at the bottom of the Xojo IDE interface (click the “RSS” feed looking icon). Other users have noted that Xojo.system.DebugLog doesn’t work; but the following syntax does work:

System.DebugLog(“Hello World”)

Again, only to the IDE’s Messages window.

It should be logging in the “Console” app on macos, on linux it writes to journal (journalctl -b) on windows to the event logger (admin tools) or DebugView.
I’m talking about System.Log

System.debuglog should write to the same tools as if it was:
System.Log(System.LogLevelDebug, “message”) that may vary per platform.

The Docs say: “On macOS and Linux, it writes to the system logger, which is typically at /var/log.”

I do not see the message in any file in /var/log.

Is this a bug that should be reported?

on 10.14.6 if you click on your machine name in the top of Console you should see it
but you probably have to filter by app name for it

I find what Apple have done with console less useful than it used to be

[quote=451371:@Norman Palardy]on 10.14.6 if you click on your machine name in the top of Console you should see it
but you probably have to filter by app name for it[/quote]

Yes, as I mentioned in my original post, I do see the message at the time it is written in the Console window… but it seems the message is not saved to any file in /var/log as described in the docs.

You will notice if you quit the Console and reLaunch it there is no way to find that same “This is a test” message. It seems to be captured by the Console in real-time but never saved anywhere…

Dunno what Xojo uses for logging
I assume its NSLog

But I believe this will go through Apple Unified logging Logging | Apple Developer Documentation
and the doc for that says

that document i lengthy but also gives you docs on how to change whether messages are saved to disk or not etc
See Customizing Logging Behavior While Debugging

You might want the section that follows about how to custoimze this for a given app identifier

[quote]You can also override the logging behavior of a specific subsystem by creating and installing a logging configuration profile property list file in the /Library/Preferences/Logging/Subsystems/ directory. Name the file using an identifier string, in reverse DNS notation, representing the subsystem. For example, com.your_company.your_subsystem_name.plist. Next, add one or more settings dictionaries to the top level of the file. A DEFAULT-OPTIONS settings dictionary defines global behavior settings for the entire subsystem. Category settings dictionaries define behavior for specific categories of messages within the subsystem. See Listing 7
[/quote]

[quote=451380:@Norman Palardy]Dunno what Xojo uses for logging
I assume its NSLog

But I believe this will go through Apple Unified logging https://developer.apple.com/documentation/os/logging?language=objc
and the doc for that says

that document i lengthy but also gives you docs on how to change whether messages are saved to disk or not etc
See Customizing Logging Behavior While Debugging[/quote]

If that is the case then the docs are wrong… I will submit a feedback.

I suspect this is something Apple simply changed and Xojo is using the correct facility but the behaviour has changed underneath and so the docs used to be correct but now the “how to” to see your messages and make them persist is a lot more complicated on macOS

I have created a feedback case: 57127

You have to use the terminal to see anything useful; the function is somewhere on this forum written by Joe.

Not on ‘puter, so hard to look up.

theres a command you can issue right in that Apple Doc I linked to
both for viewing and chnaging it so messages are persisted
see after View Log Messages

I had always found using the System Log to be cumbersome, slow, and sometimes actually out of synch with the events it should be logging…
So I wrote this small method, which seems to actually be faster, and never out of synch… not to mention easy to find the results as each app can create its own log file.

Public Sub WriteLog(msg As String)
  Dim f As FolderItem
  Dim t As TextOutputStream
  Dim path As String=app.ExecutableFile.DisplayName
  Dim x As Integer
  x=InStr(path,".")
  If x>0 Then path=Left(path,x-1)
  f=SpecialFolder.Desktop.child(path+".log")
  If msg="!!!" And f.exists Then
     f.Delete
    Exit Sub
  End If
  If Not f.exists Then
    t=TextOutputStream.Create(f)
  Else
    t=TextOutputStream.Append(f)
  End If
  t.Write msg+EndOfLine
  t.Close
End Sub

System log is definitely faster than appending to a text output stream
it skips all the file opening closing seeking to the end etc

really

[quote=451465:@Norman Palardy]System log is definitely faster than appending to a text output stream
it skips all the file opening closing seeking to the end etc

really[/quote]
far from what I have observed…but I offer only as an alternative… not a requirement

@Jim Meyer — I have always preferred to use another debugging system which accepts any kind of values and report them in a useful way, namely the DebugReport module in MacOSLib.

system.debuglog uses the system logging service which is designed to log EVERY log message sent by the entire running OS and every app running on it - kernel apps kexts etc etc etc - hundreds if not thousands of processes

folderitem appending simply isnt as fast

fine… it isn’t as fast… but not by so much as to impact a debugging session

System.Debug is lightning fast (it wasn’t so much a few versions ago)… 10,000 repetions <0.6 seconds
my routine… 10,000 reptitions 2.2 seconds (only 0.00022 seconds per log event)… big deal

The major advantage… you don’t have to “look” for the messages,

Again… use it or don’t… not worth arguing about

FYI in Console you can use the filter and see just your messages by using the filter field in the upper right
Can filter by process name, app bundle id and many other things
It help get rid of the “hunting for messages”
Which logging it manually to a specific location like you do also does
There are times that manually logging induces slowness and that can be a problem
The IDE has this issue at times if you use system.debuglog in a tight loop

Logging to the Mac system logs has been borked for at least a couple of years in Xojo now. At best it’s intermittent, at worst it flat out doesn’t work.

I can log reliably on Windows in Xojo.
I can log reliably on Linux in Xojo.
I can log reliably in Xcode from Swift and Objective-C on the Mac.
I can’t log reliably in Xojo on the Mac.