Event ID 307 is what I was after, it had all the pertinent information I needed to build my log with:
What I didn't realize originally is that Event ID 805 contains the number of copies for a given Job ID. Why this isn't included in Event ID 307 I'm not entirely sure but oh well. In order to get the proper accounting I needed a script that would write out to a file the Job Id and the number of copies. Then the print logging script would read it in, and write the count out with the rest of the data.
Originally this script was tied to an event and when that event occurred it would attempt to get the most recent (ie the one that triggered it). I found a wonderful article on TechNet
about how to pass the EventRecord to a script. This allows me to parse the actual event that occurred. Since you have to modify the task I included two XML files that you can import into your Event Tasks that are already configured.
To get things up and running there are a few steps that need to be gone through first and then you can get started. Once everything is setup the script will start working on it's own. The nice thing about it is, if the log file doesn't exist it will create
it for you. Since the filenames are based on the date, this means it should roll over for you every 24 hours.
Setup an Event Triggered Task Or import the XML files
About 6mo ago I decided that I wanted to start writing this information out to a SQL database, so the script now writes data out to a csv, as well as logs it to your sql server. To setup a SQL database is a bit beyond this particular article, but what I did was create a database on the default SQL instance. Within that database I created a table, and populated it with the following fields
Column Name | Data Type |
Time | Datetime |
UserName | varchar(50) |
Pages | int |
DocumentName | ntext |
Client | varchar(50) |
Size | bigint |
Printer | varchar(50) |
Port | varchar(50) |
Job | int |
Copies | int |
Finally I created a sql user, assigned a password and created a login for it in the database. That user only has the ability to insert into the table and only has access to that particular table. I left in the code to write to csv as I think that's handy
and a nice builtin backup. Feel free to comment out the parts you don't want, I'm thinking I may update this slightly so if you don't pass in any SQL information it doesn't write anything out to SQL.
That's pretty much it, I do in fact use this in production, I think this particular version works much better than in the past. I have a script that is included in the download
page on the TechNet Gallery that shows how to query the table for yesterday's print jobs. Here is a sample of the output I receive from that script each morning.
DateSubmitted : 5/1/2012
PrintJobs : 2067
PagesPrinted : 9544
UsersPrinting : 414
MaxJob : 211
ReamsUsed : 19.088
BoxesUsed : 1.9088