Docs Menu
Docs Home
/ /

Database Tools 로그

MongoDB Database Tools는 로그를 stderr로 인쇄합니다.

다음 예는 mongoexport 작업의 결과와 stderr에 기록된 정보를 보여줍니다.

test.cakeSales collection의 콘텐츠에서 cakeSales.json 파일을 생성하는 다음 mongoexport 작업을 고려합니다.

mongoexport --db=test --collection=cakeSales --out=cakeSales.json

mongoexport 다음 정보를 stderr에 기록합니다.

2021-09-21T14:05:07.197-0400 connected to: mongodb://localhost/
2021-09-21T14:05:07.203-0400 exported 6 records

대상 배포에 연결할 수 없어 실패한 다음 mongoexport 작업을 고려하세요.

mongoexport --host=notRealHost.example.net --port=27017 --username=someUser --authenticationDatabase=admin --collection=contacts --db=marketing --out=mdb1-examplenet.json

mongoexport 다음 정보를 stderr에 기록합니다.

2021-09-21T14:35:30.125-0400 could not connect to server: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: notrealhost.example.net:27017, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp: lookup notrealhost.example.net: no such host }, ] }

stderr 로그의 내용을 쉽게 볼 수 있도록 파일로 출력하거나 Database Tools 작업 결과를 저장할 수 있습니다.

stderr 출력을 파일로 파이프하려면 명령에 2> {fileName} 을 추가합니다.

다음 명령은 mongoexport 작업의 출력을 mongoexport.log 파일에 씁니다. 이 예제에서는 명령이 실행되는 동일한 디렉토리에 mongoexport.log 파일이 생성됩니다.

mongoexport --db=test --collection=cakeSales --out=cakeSales.json 2> mongoexport.log

mongoexport.log 의 내용을 보려면 텍스트 편집기에서 파일을 엽니다.

돌아가기

Windows

이 페이지의 내용