Hi,
Our team is facing an issue where the os log message is not fully printed in the Xcode console. Even when using Debug → Attach to Process by PID or Name, the logs appear truncated (Both simulator and physical device). We noticed that the Xcode 15.0 release notes we saw that there is some truncation made for debug lines in console. We also tried checking the logs using Console.app, but the truncation remains. If limitation is there how much maximum lines it can print ? Could anyone please provide guidance on how we can view the complete logs? Any suggestions or workarounds would be highly appreciated.
Log message truncation is a bit tricky because it happen at both the system log and the Xcode level. However, if you’re seeing log message truncation in Console, so without Xcode in the mix, then you’re hitting the system log entry limit.
If limitation is there how much maximum lines it can print ?
It’s not about lines, it’s about size. Specifically, the size of the log entry, as it’s sent to the log subsystem, is limited to 1024 bytes.
Consider this coded:
for size in stride(from: 960, through: 1040, by: 16) {
let message = repeatElement("0123456789abcdef", count: size / 16).joined()
log.log("size: \(size), message: \(message, privacy: .public)")
}
If you monitor that in Console, you’ll see that the size: 992, message: …
message arrives intact but the size: 1008, message: …
message gets truncated. That’s the 1024 limit, minute a bit for the other fields in the log entry.
You can find this limitation documented in the os_log
man page (in section 5). I have links to this and many other resources in Your Friend the System Log.
As to what you should do about this, it depends on the reason you’re logging such large messages:
-
If you’re doing
printf
debugging, and you intend to remove these log entries before shipping your app, then the easiest option is to switch toprint(…)
. It’s output doesn’t go through the system log and thus is not subjet to this truncation. -
If you plan to leave these logs enabled in your final app then… well… we should talk more about your goals. The system handles a lot of log entries, and part of its success is limiting the size of those messages.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"