community.windows.win_eventlog_entry 模块 – 向 Windows 事件日志写入条目
注意
此模块是 community.windows 集合(版本 2.3.0)的一部分。
如果您使用的是 ansible 包,您可能已经安装了这个集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.windows。
要在 Playbook 中使用它,请指定:community.windows.win_eventlog_entry。
概要
- 从指定的源将日志条目写入给定的事件日志。 
参数
| 参数 | 说明 | 
|---|---|
| 与日志源的类别消息文件关联的数字任务类别。 | |
| 指示写入日志的条目是特定类型。 选择 
 | |
| 条目的数字事件标识符。 值必须在 0 到 65535 之间。 | |
| 要写入条目的事件日志的名称。 | |
| 给定日志条目的消息。 | |
| 与日志条目关联的二进制数据。 值必须是 8 位无符号整数(0 到 255)的逗号分隔数组。 | |
| 指示条目来源的日志源的名称。 | 
说明
注意
- 写入事件条目时,此模块始终会报告更改。 
另请参阅
另请参阅
- community.windows.win_eventlog
- 管理 Windows 事件日志。 
示例
- name: Write an entry to a Windows event log
  community.windows.win_eventlog_entry:
    log: MyNewLog
    source: NewLogSource1
    event_id: 1234
    message: This is a test log entry.
- name: Write another entry to a different Windows event log
  community.windows.win_eventlog_entry:
    log: AnotherLog
    source: MyAppSource
    event_id: 5000
    message: An error has occurred.
    entry_type: Error
    category: 5
    raw_data: 10,20
