Apple's Unified Logging
documentation states:
Don’t include symbolication information or source file line numbers in messages. The system automatically captures this information.
But in Console I don't see a filename, class name, function name, or line numbers.
How can I have those in my logs?
os_log
doesn't currently give line numbers/function names for Swift code in Console.app, or through thelog stream
command.If you really need it - you can use Literal Expressions to pass the information manually via
NSLog
oros_log
like this:os_log(.info, "Log message from file: %s, line: %i, column: %i", #file, #line, #column)
It may be tempting to wrap
os_log
to always include this information, but Apple suggests not doing so for performance reasons.