muthukumar
muthukumar

Reputation: 2243

Windows Event log file

I have a program which reads a file every time and now I want to read the event log file of windows ,how can I get the location and read its contents.

The logs are stored in the %SystemRoot%\System32\Config directory with a .evt extension. Within the Computer Manager you can also export them to a .txt or .csv file.

Windows Vista/7/Server2008 location, here it is: %SystemRoot%\system32\winevt\logs

My Code is:

String fileSeperator = File.separator;
String filePath = "C:" + fileSeperator + "WINDOWS" + fileSeperator + "system32" + fileSeperator + "winevent" + fileSeperator + "logs";
System.out.println("FilePath :" + filePath);
File f = new File(filePath);
System.out.println("Is Directory :" + f.isDirectory());

The Output:

FilePath : C:\WINDOWS\system32\winevent\logs

Is Directory :false

Why does it return it is not a directory?

Upvotes: 0

Views: 1207

Answers (1)

JB Nizet
JB Nizet

Reputation: 691775

Because the file doesn't exist. You said yourself that the location was %SystemRoot%\system32\winevt\logs. Yet you use C:\WINDOWS\system32\winevent\logs.

winevt != winevent.

Upvotes: 2

Related Questions