Hide OS logs coming out of the Network framework (category: com.apple.network)

I'm establishing a connection with NWListener and NWConnection which is working great. However, if the listener disappears, a lot of logs are appearing:

Is there a way to hide these logs?

  • I'm aware of OS_ACTIVITY_MODE=disabled, but that will also hide a lot of other logs.
  • I also know you can hide these using Xcode's filtering. I'm looking for a programmatically way to hide these completely. I'm not interested in seeing these at all, or, at least, I want to be in control.

Thanks!

Answered by DTS Engineer in 834382022

I don’t think there’s a way to attain your specific goal. While the system log gives you control over what gets logged — I have a lot of info about that in Your Friend the System Log — Xcode has its own mechanism for catching system log entries. This sees the entries before they make it to the system log, which means the decision as to what shows up in Xcode in entirely under its control. It has a default policy and then applies whatever filter you set up.

Which brings me to:

Written by AvdLee in 780287021
I also know you can hide these using Xcode's filtering.

Why isn’t that sufficient in your case?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I don’t think there’s a way to attain your specific goal. While the system log gives you control over what gets logged — I have a lot of info about that in Your Friend the System Log — Xcode has its own mechanism for catching system log entries. This sees the entries before they make it to the system log, which means the decision as to what shows up in Xcode in entirely under its control. It has a default policy and then applies whatever filter you set up.

Which brings me to:

Written by AvdLee in 780287021
I also know you can hide these using Xcode's filtering.

Why isn’t that sufficient in your case?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

To me, it feels like the Network framework should provide an option to enable debug logging or not. In fact, it turns out I could do that for some of those logs:

let privacyContext = NWParameters.PrivacyContext(description: "Logging Disabled")
privacyContext.disableLogging() // Disable system logging for this context

However, there are still quite some logs emitted.

Written by DTS Engineer in 834382022
Why isn’t that sufficient in your case?

Xcode filtering is something you'll have to configure again and again, I am never interested in these logs so I want them to be hidden always.

On top of that, I'm providing a library to 3rd party developers which I'm now annoying with logs from the Network framework that I'm not even interested in myself.

Let me know if that makes sense!

Written by AvdLee in 834452022
To me, it feels like the Network framework should provide an option to enable debug logging or not.

Hmmmm, that seems suboptimal. If you disabled network logging in your library and shipped it to a bunch of folks, that’d seriously compromise your ability to debug problems that only show up in the field.

IMO solutions need to come from the presentation side, not the generation side.

Written by AvdLee in 834452022
Xcode filtering is something you'll have to configure again and again

Indeed. I think you could make a case that Xcode should preserve this filter.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Written by DTS Engineer in 834618022
If you disabled network logging in your library and shipped it to a bunch of folks, that’d seriously compromise your ability to debug problems that only show up in the field.

I believe we're on the same page, yet, I want it to be opt-in. I'm offering a debug mode for my library, but I at least want to offer a way to enable/disable it. Right now, I'm cluttering the console for implementors without a way for them to always turn it off.

If all 3rd party libraries would enable logging without a way to turn it off, developers would have to configure all kinds of category filters inside Xcode. That doesn't sound like something we should want?

Hide OS logs coming out of the Network framework (category: com.apple.network)
 
 
Q