728x90
win32evtlogutil을 사용하면 파이썬 코드로 윈도우 이벤트를 간편하게 기록할 수 있습니다.
사용 예제 코드(main.py)는 다음과 같습니다.
import win32evtlogutil
import win32evtlog
win32evtlogutil.ReportEvent(
appName="AppName",
eventID=1234,
eventCategory=9876,
eventType=win32evtlog.EVENTLOG_WARNING_TYPE,
strings=["event message1", "event message2"],
data=b"\x01\x02\x03\x04"
)
코드를 다음과 같이 실행합니다.
python main.py
실행된 결과를 확인하기 위해 eventvwr.msc를 실행합니다.
이벤트로그가 기록되었음을 확인할 수 있습니다.
728x90
'Python' 카테고리의 다른 글
[python] matplotlib 설치하기 (0) | 2022.05.13 |
---|---|
파이썬 코드로 윈도우 이벤트 읽기 (0) | 2022.05.09 |
python datetime 비교 (0) | 2022.04.21 |
python 문자열을 datetime객체로 변경하는 방법 (0) | 2022.04.21 |
[python] openpyxl을 이용하여 엑셀파일 다루기 (0) | 2022.03.13 |