https://github.com/dhcgn/powershell-convert-iis-logs-w3c
Get type safe log entries from an IIS Log file in W3C format
https://github.com/dhcgn/powershell-convert-iis-logs-w3c
Last synced: 5 months ago
JSON representation
Get type safe log entries from an IIS Log file in W3C format
- Host: GitHub
- URL: https://github.com/dhcgn/powershell-convert-iis-logs-w3c
- Owner: dhcgn
- Created: 2015-01-22T20:32:00.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T19:27:30.000Z (about 3 years ago)
- Last Synced: 2024-05-01T12:47:40.200Z (over 1 year ago)
- Language: C#
- Size: 911 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PowerShell Convert IIS Logs (W3C)
Convert log entries from an IIS Log file in W3C format to a friendly format.
Build Status: [](https://travis-ci.org/dhcgn/PowerShell-Convert-IIS-Logs-W3C-)
## Install
```Powershell
Import-Module "C:\temp\ConvertFromIISLogFile.dll" -Verbose
```
Very simple, just import the ddl-file. You should consider to put this cmd in your powershell profil.
![][Install]
[Install]: http://i.imgur.com/hF5HPC3.png
## Usage
```Powershell
ConvertFrom-IISLogFile C:\temp\u_ex150113.log | Select-Object -First 10
```
![][SimpleUsage]
[SimpleUsage]: http://i.imgur.com/otiONvb.png
## Return Type
```
TypeName: ConvertFromIISLogFile.LogEntry
Name MemberType Definition
---- ---------- ----------
IP AliasProperty IP = ClientIpAddress
Query AliasProperty Query = UriQuery
Receive AliasProperty Receive = ServerReceivedBytes
Sent AliasProperty Sent = ServerSentBytes
Status AliasProperty Status = HttpStatus
Target AliasProperty Target = UriStem
Timestamp AliasProperty Timestamp = DateTimeLocalTime
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
ClientIpAddress Property ipaddress ClientIpAddress {get;set;}
Date Property datetime Date {get;set;}
DateTime Property datetime DateTime {get;}
DateTimeLocalTime Property datetime DateTimeLocalTime {get;}
HttpStatus Property string HttpStatus {get;set;}
Method Property string Method {get;set;}
Port Property int Port {get;set;}
ProtocolSubstatus Property string ProtocolSubstatus {get;set;}
Referrer Property string Referrer {get;set;}
ServerReceivedBytes Property int ServerReceivedBytes {get;set;}
ServerSentBytes Property int ServerSentBytes {get;set;}
SourceIpAddress Property ipaddress SourceIpAddress {get;set;}
SystemErrorCodes Property string SystemErrorCodes {get;set;}
Time Property datetime Time {get;set;}
TimeTaken Property int TimeTaken {get;set;}
UriQuery Property string UriQuery {get;set;}
UriStem Property string UriStem {get;set;}
UserAgent Property string UserAgent {get;set;}
Username Property string Username {get;set;}
```
### Return Type Explanation
```C#
using System;
using System.Net;
namespace ConvertFromIISLogFile
{
///
/// W3C Extended Log File Format
/// http://www.w3.org/TR/WD-logfile.html
///
/// Table 10.1 W3C Extended Log File Fields
/// http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/676400bc-8969-4aa7-851a-9319490a9bbb.mspx?mfr=true
///
public class LogEntry
{
///
/// The date on which the activity occurred.
///
/// Field: date
///
public DateTime Date { get; set; }
///
/// The time, in coordinated universal time (UTC), at which the activity occurred.
///
/// Field: time
///
public DateTime Time { get; set; }
///
/// The date and time (UTC) on which the activity occurred.
///
public DateTime DateTime => new DateTime(this.Date.Year, this.Date.Month, this.Date.Day, this.Time.Hour, this.Time.Minute, this.Time.Second);
///
/// The date and time (Local) on which the activity occurred.
///
public DateTime DateTimeLocalTime => DateTime.SpecifyKind(this.DateTime, DateTimeKind.Utc);
///
/// Field: s-ip
///
public IPAddress SourceIpAddress { get; set; }
///
/// The requested action, for example, a GET method.
///
/// Field: cs-method
///
public string Method { get; set; }
///
/// The target of the action, for example, Default.htm.
///
/// Field: cs-uri-stem
///
public string UriStem { get; set; }
///
/// The query, if any, that the client was trying to perform. A Universal Resource Identifier (URI) query is necessary only for dynamic pages.
///
/// Field: cs-uri-query
///
public string UriQuery { get; set; }
///
/// The server port number that is configured for the service.
///
/// Field: s-port
///
public int Port { get; set; }
///
/// The name of the authenticated user who accessed your server. Anonymous users are indicated by a hyphen.
///
/// Field: cs-username
///
public string Username { get; set; }
///
/// The IP address of the client that made the request.
///
/// Field: c-ip
///
public IPAddress ClientIpAddress { get; set; }
///
/// The browser type that the client used.
///
/// Field: cs(User-Agent)
///
public string UserAgent { get; set; }
///
/// The site that the user last visited. This site provided a link to the current site.
///
/// Field: cs(Referrer)
///
public string Referrer { get; set; }
///
/// The HTTP status code.
///
/// Field: sc-status
///
public string HttpStatus { get; set; }
///
/// The substatus error code.
///
/// Field: sc-substatus
///
public string ProtocolSubstatus { get; set; }
///
/// Win32 error code
/// Field: sc-win32-status
///
/// https://msdn.microsoft.com/en-us/library/ms681381.aspx
///
public string SystemErrorCodes { get; set; }
///
/// The number of bytes that the server sent.
///
/// Field: sc-bytes
///
public int ServerSentBytes { get; set; }
///
/// The number of bytes that the server received.
///
/// Field: cs-bytes
///
public int ServerReceivedBytes { get; set; }
///
/// The length of time that the action took, in milliseconds.
///
/// Field: time-taken
///
public int TimeTaken { get; set; }
}
}
```
### Debugging
Start external program: ```C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe```
Command line arguments: ```-noexit -noprofile -command "&{ import-module "PathToDLL\ConvertFromIISLogFile.dll" -verbose;}"```
or
Command line arguments: ```-noexit -noprofile -command "&{ import-module "PathToDLL\ConvertFromIISLogFile.dll" -verbose; New-Variable -Value (Export-IISLogStats -InputFiles (gci PathToLogFiles) -Resolution Hour -Verbose) -Name log -Visibility Public -Scope Global }"```