James Franco
James Franco

Reputation: 4726

`Launchd` based logging - where does `log show` get its data from

I would like my logs to show up when I do something like this

log show --debug --info | grep "Myapp"

I am currently doing something like this in launchd which writes to a flat file.

<key>StandardOutPath</key>
<string>/var/app/s.log</string>
<key>StandardErrorPath</key>
<string>/var/app/e.log</string>

I would like to know how I can adjust the above so that my logs can be shown using log show. Is there a specific path that log show commands reads its contents from ?

Primarily what I would like to do is adjust the above launchd snippet so that the output gets sent to system logs and I am not sure which files are read and displayed there

Upvotes: 1

Views: 1180

Answers (1)

Motti Shneor
Motti Shneor

Reputation: 2194

To see your logs in log show you must first WRITE your logs to the os_log system.

You have not provided any context about your objective -- not even what kind of software you're writing. I don't know why you introduced the word "launchd" in your question - as if it relates somehow to the logging system (it's not).

Provided that you write your software in C or Objective-C or C++ -- then you'll need to import <os_log/os_log.h> into your code, and learn how to

  1. create a log object
  2. emit log lines in your code

Then - your logs will appear in Log-show.

If you're writing in swift - its about the same.

Other than that -- I'll need more information to help you specifically.

Upvotes: 0

Related Questions