장치에 데이터 로깅 및 로그 검색
Xcode의 디버그 빌드에서 시뮬레이터 또는 실제 장치를 사용하는지 여부에 관계없이 NSLog, printf, fprintf assert 및 NSAssert 문이 콘솔에 표시됩니다.
이제 장치에서 릴리스 빌드를 실행하면 (예 : 테스트 플라이트 빌드를 보내고 내 iPhone에 크게 올리면 릴리스 빌드가됩니다.)이 중 어떤 것이 (있는 경우) 기록되고 있습니까?
그리고 어떻게 로그를 검색합니까?
NSLog는 실제로 릴리스 빌드에서 무언가를 출력합니까? 결정 요인은 무엇입니까? stdout 또는 stderr에 쓰고 있습니까? 장치 로그에 stderr 만 기록됩니까? 이것은 내가 fprintf를 사용해야 함을 의미합니까? 장치 로그에 기록 된 것이 있습니까? 그런 것조차 있습니까? 그렇다면 어떻게 픽업합니까?
누군가 상황을 명확히 할 수 있습니까?
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName =[NSString stringWithFormat:@"%@.log",[NSDate date]];
NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:fileName];
freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);
application:didFinishLaunchingWithOptions
앱 델리게이트 파일의 메서드 에이 코드 블록을 추가하기 만하면 모든 콘솔 로그 이벤트를 기록하는 iPhone의 앱 문서 디렉토리에 로그 파일이 생성됩니다. 모든 콘솔 이벤트를 보려면 iTunes에서이 파일을 가져와야합니다.
참고 : .plist 파일에서 파일 Application supports iTunes file sharing
이 존재하고 YES
iTunes를 통해 액세스 할 수 있도록 설정되어 있는지 확인하십시오 .
로그 파일을 얻으려면 : iTunes를 실행하고 장치가 연결된 후 앱을 선택하고 앱을 선택합니다. Augument Document에서 파일을 가져옵니다. 그런 다음 디스크에 저장할 수 있습니다.
Xcode 6.1.1에서는 다음을 수행하여 NSLog 출력을 볼 수 있습니다. 그러나 너무 오래 전의 로그를 볼 수 있는지 확실하지 않습니다. 나는 그것이 몇 시간까지 되돌아가는 것을 보았다.
어쨌든 다음 단계는 다음과 같습니다.
- Xcode에서 창-> 장치로 이동하십시오.
- 왼쪽 패널에서 장치를 선택하십시오.
- 아래 스크린 샷과 같이 작은 화살표를 클릭합니다.
Swift 3.0에서는 Shyl의 코드가 다음과 같이 변경됩니다.
var paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let documentsDirectory = paths[0]
let fileName = "\(Date()).log"
let logFilePath = (documentsDirectory as NSString).appendingPathComponent(fileName)
freopen(logFilePath.cString(using: String.Encoding.ascii)!, "a+", stderr)
다른 모든 과정은 Shyl이 설명하는 것과 동일합니다.
앱 델리게이트 파일의 application : didFinishLaunchingWithOptions 메소드에이 코드 블록을 추가하면 모든 콘솔 로그 이벤트를 기록하는 iPhone의 앱 문서 디렉토리에 로그 파일이 생성됩니다. 모든 콘솔 이벤트를 보려면 iTunes에서이 파일을 가져와야합니다.
참고 : .plist 파일에서 파일이
Application supports iTunes file sharing
존재하고YES
iTunes를 통해 액세스 할 수 있도록 설정되어 있는지 확인하십시오 .로그 파일을 얻으려면 : iTunes를 실행하고 장치가 연결된 후 앱을 선택하고 앱을 선택합니다. Augument Document에서 파일을 가져옵니다. 그런 다음 디스크에 저장할 수 있습니다.
NSLog is written to device log in production release and you can check this by connecting your iPhone to your system and using Organizer. Select your iPhone in the organizer, click Device Logs. You would see all NSLog outputs in the log.
I found this link from APPLE very informative and complete. It pretty much gives you all the options to see or access logs of the device whether or not they are connected to your dev machine.
https://developer.apple.com/library/ios/qa/qa1747/_index.html
Yes, NSLog outputs on the device. You can see it's outputs with your device connected to your Mac and using Xcode Organizer tool.
If you use Testflight SDK, you can capture all logs with their Remote Logging feature.
I know this is an old thread but you can also have access to the device logs going to:
설정-> 개인 정보-> 분석-> 데이터
이 도움을 바랍니다
문안 인사
Xcode 9.3에서 장치 로그 화면이 새 위치로 이동했다고 생각합니다. 친절하게 다음 링크를 참조하십시오.
참고 URL : https://stackoverflow.com/questions/9097424/logging-data-on-device-and-retrieving-the-log
'Program Tip' 카테고리의 다른 글
문자열 내에서 변수 사용 (0) | 2020.10.22 |
---|---|
CollectionView sizeForItemAtIndexPath가 호출되지 않았습니다. (0) | 2020.10.22 |
null의 'addEventListener'속성을 읽을 수 없습니다. (0) | 2020.10.22 |
Magento에서 매장 정보를 얻는 방법은 무엇입니까? (0) | 2020.10.22 |
HH : MM : SS 문자열을 자바 스크립트에서만 초로 변환 (0) | 2020.10.22 |