Write to Windows event log: Difference between revisions
Content added Content deleted
(Added Go) |
|||
Line 333: | Line 333: | ||
log.Source <- "Sample Application" |
log.Source <- "Sample Application" |
||
log.WriteEntry("Entered something in the Application Eventlog!")</lang> |
log.WriteEntry("Entered something in the Application Eventlog!")</lang> |
||
=={{header|Go}}== |
|||
This works on Windows 10 with administrative privileges. |
|||
<lang go>package main |
|||
import ( |
|||
"fmt" |
|||
"os/exec" |
|||
) |
|||
func main() { |
|||
command := "EventCreate" |
|||
args := []string{"/T", "INFORMATION", "/ID", "123", "/L", "APPLICATION", |
|||
"/SO", "Go", "/D", "\"Rosetta Code Example\""} |
|||
cmd := exec.Command(command, args...) |
|||
err := cmd.Run() |
|||
if err != nil { |
|||
fmt.Println(err) |
|||
} |
|||
}</lang> |
|||
=={{header|Java}}== |
=={{header|Java}}== |