【OSLog】How to log a Swift project
![イメージ](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPcJmdMwiRh4qXqlqZve2KbNXPJUbuIuzfYagtScTXmHDcbXqGj1Ri5sRNZFWz0WW75kxhLmZkTuLJYmtPZyfddf3etBfj1LF3MXTNRE0FXyjVKLAQAmFyIX2U_FKB7MyhbsmNS05wzha5OQv3MzYnM0e9py0VoZwiYYkS-n7nI8X69Ob56DCsc6OPKmOs/w640-h640/swift-og.png)
Overview I found an article on the net that summarized how to use OSLog, I wanted a working sample. I am new to logging, so I wasn’t sure how to interpret the usage of OSLog. So I summarized it in my own way. What is OSLog? It is a library for logging that is provided by Apple and can be used in Swift projects. The official documentation is here . Sample https://github.com/Kuehar/OSLogSample When the above code is run, eight buttons are lined up as shown below. import SwiftUI import OSLog struct ContentView: View { let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ApplicationCode") var body: some View { VStack { Button(action: { logger.trace("Trace Log") }, label: { Text("Trace") }) Button(action: { logger.debug("Debug Log") }, label: { Text("Debug")