Selenium-wire Python을 사용하여 네트워크 트래픽을 캡처하는 동안 다른 형식의 로그 보기 (Seeing logs in a different format while capturing network traffic using selenium-wire python)


문제 설명

Selenium‑wire Python을 사용하여 네트워크 트래픽을 캡처하는 동안 다른 형식의 로그 보기 (Seeing logs in a different format while capturing network traffic using selenium‑wire python)

웹 사이트 백엔드에서 웹 서비스의 http 요청을 캡처하는 동안 일부 로그가 다른 형식으로 표시됩니다. 저는 python 로깅을 형식으로 사용하고 있습니다.

logging.basicConfig(format='%(asctime)s %(levelname)‑4s %(message)s', 
                    level=logging.INFO,
                    datefmt='%Y‑%m‑%d %H:%M:%S'`enter code here`, 
                    filemode='a')

logging.info("%3s %s %s", request.response.status_code, driver.current_url, request.path)

출력으로 표시될 것으로 예상됩니다.

2020‑02‑10 14:00:56 INFO  204   https://driver.current_url         https://request_path

그러나 이 형식 외에 다른 로그 형식도 아래와 같이 표시됩니다.

2020‑02‑10 13:35:08 INFO  Capturing request: https://request_path 
2020‑02‑10 13:35:08 INFO  Capturing response: https://request_path 200 OK 

이 로그를 보는 이유를 알려줄 수 있는 사람이 있습니까?


참조 솔루션

방법 1:

Python has the possibility to have multiple loggers. basicConfig configures the root logger, but it's possible other libraries configure their own loggers.

In order to configure those loggers, you would need to know the library's logger's name and call "getLogger(" the name ")" in order to get the logger to be able to configure it.

Please see Python's logging cookbook for more info.

(by sophie_denSam)

참조 문서

  1. Seeing logs in a different format while capturing network traffic using selenium‑wire python (CC BY‑SA 2.5/3.0/4.0)

#python-logging #capture #selenium #seleniumwire






관련 질문

로깅 모듈 이상, 로그 메시지의 잘못된 표시? (Logging module weirdness, wrong display of log message?)

GCP Kubernetes의 Python 로깅 (Python logging in GCP kubernetes)

선언하기 전에 logging.info()를 호출하면 Python의 logging.basicConfig가 작동하지 않습니다. (logging.basicConfig in Python won't work if calling logging.info() before declaring)

예외 경우에 인쇄되는 오류 메시지를 사용자에게 이메일로 어떻게 보내나요? (How to send an error message being printed in an exception case by email to a user?)

Selenium-wire Python을 사용하여 네트워크 트래픽을 캡처하는 동안 다른 형식의 로그 보기 (Seeing logs in a different format while capturing network traffic using selenium-wire python)

파이썬에서는 콘솔에 로그를 쓸 수 있지만 파일에는 기록되지 않습니다. (In python I can write a log to console but its not getting written into file)

다른 모듈에서 사용자 정의 로거 처리 (Handling custom logger across different modules)

로깅 인스턴스화에 대한 Python 평가 순서입니다. 가져온 모듈이 먼저 평가되는 이유는 무엇입니까? (Python order of evaluation for a logging instantiation. Why do imported modules get evaluated first?)

X일보다 오래된 로그 파일 삭제 (Delete log files older than X days)

logging.config.fileConfig를 호출하면 로깅 시스템이 여러 번 실패합니다. (Logging system fails multiple times when I call logging.config.fileConfig)

python - 메소드 이름에 대한 미리 정의된 내장 (python - predefined builtlin for method name)

사용자 정의 클래스에서 로거를 래핑하는 동안 문제 발생 (Issue while wrapping logger in custom class)







코멘트