2

Is it possible to read the Windows-eventlogItems using GVim? Our application logs errors in the eventlog, it would be nice if I could read them using GVim.

A daily export to file is not an option: it should be instant : error happens, switch to GVim, read details of the last X items.

2 Answers 2

1

You have to export the events everytime you want to look at them.

Route One: Use wevtutil and logparser to create some .txt

 % wevtutil epl XYZ %TEMP%\log.evtx

Then you install LogParser and use it like this:

 % logparser -i:evt -o:csv "SELECT * INTO %TEMP%\log.csv FROM %TEMP%\log.evtx"

After which you can

 % gvim %TEMP%\log.csv

Note: Replace 'XYZ' in the first line with whatever part of the event log you are interested at, these snippets should get you started.

Check out http://martin77s.wordpress.com/tag/logparser/ as well.

Route Two: Use psloglist from Sysinternals and use it like this:

 :%!psloglist -h 1 -o XYZ

where XYZ is the event source (maybe the name of your app). Looks simpler to me.

8
  • Yes, I am hoping such an export tool exists, with possibility to filter last x items.
    – Sotto
    Jan 31, 2011 at 17:27
  • @akira: I thought the events are xml files on Vista/2008 onwards. en.wikipedia.org/wiki/Event_Viewer
    – paradroid
    Jan 31, 2011 at 19:02
  • You might take a look at the Vim plugins that automatically translate non-text files when they're opened (e.g., $VIMRUNTIME/plugin/gzip.vim or $VIMRUNTIME/plugin/tarPlugin.vim) and see if you can do all those steps that akira gave automatically. Then all you would have to do is open the eventlog file with gvim and the text version would just appear.
    – garyjohn
    Jan 31, 2011 at 19:20
  • @akira: I know that. I was suggesting that it might not be too much work to write one.
    – garyjohn
    Jan 31, 2011 at 19:35
  • Thanks! tracking down errors has become much more easier now! something like psloglist is exactly what i was hoping for
    – Sotto
    Feb 2, 2011 at 22:04
0

You can export the Event Log to an file. In Windows 7 right click on the event category and choose "Save All Events As". I believe that exists in previous versions of Windows as well. Then you can edit that file with Vim.

1
  • using vim and clicking around like crazy just does not fit the mentality of a vim user, trust me :)
    – akira
    Feb 1, 2011 at 8:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .