2025-04-27 07:49:33 -04:00

177 lines
5.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<TITLE>OpenLogFile</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
TempString = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer"){
// Check to see if browser is Microsoft
if (TempString.indexOf ("4.") >= 0){
// Check to see if it is IE 4
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
}
}
else if (navigator.appName == "Netscape") {
// Check to see if browser is Netscape
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
//-->
</script>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
Dim frmContents
On Error Resume Next
If Not Parent Is Nothing Then
Set frmContents = Parent.Contents
If Not frmContents Is Nothing Then
frmContents.Window.TOCSynch_Click
End If
End If
End Sub
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="MS-IT-LOC" Content="Internet Information Services">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H3><A NAME="_openlogfile"></A><SUP></SUP>OpenLogFile</H3>
<P>This method allows you to open a log file for reading or writing using the IISLog object.</P>
<H6>Syntax</H6>
<P><I>OIISLog</I><B>.OpenLogFile(</B> <I>FileName</I>, <I>IOMode</I>, <I>ServiceName</I>, <I>ServiceInstance</I>, <I>OutputLogFileFormat</I> <B>)</B></P>
<P><B>&nbsp;</B></P>
<H6>Parameters</H6>
<DL>
<DT><I>FileName</I></DT>
<DD>Name of the log file to open.<BR>
</DD>
<DT><I>IOMode</I></DT>
<DD>Parameter indicating whether the log file is opened for reading or writing. This parameter can take one of the following values:
<TABLE border=0 cellpadding=5 cols=3 frame=box rules=all>
<TR VALIGN="top">
<TD class=blue width=31%><B>Constant</B></TD>
<TD class=blue width=32%><B>Value</B></TD>
<TD class=blue width=37%><B>Description</B></TD>
</TR>
<TR VALIGN="top">
<TD width=31%>ForReading</TD>
<TD width=32%>1</TD>
<TD width=37%>Opens the specified log file for reading.</TD>
</TR>
<TR VALIGN="top">
<TD width=31%>ForWriting</TD>
<TD width=32%>2</TD>
<TD width=37%>Opens the specified log file for writing.</TD>
</TR>
</TABLE><BR>
<BR>
</DD>
<DT><I>ServiceName</I></DT>
<DD>Parameter indicating the logging module should only return records matching this service.<BR>
</DD>
<DT><I>ServiceInstance</I></DT>
<DD>Parameter indicating the logging modules should only return records matching this server instance.<BR>
</DD>
<DT><I>OutputLogFileFormat</I></DT>
<DD>Parameter indicating the format for log files opened for writing.</DD>
</DL>
<P><span class=le><B>Important</B></span> </P>
<P>None of the parameters are optional</P>
<H6>Example</H6>
<P>The following example opens a log file in the <B>W3C Extended Log File Format</B>, and writes its contents to another log file in the <B>NCSA Common Log File Format</B>.</P>
<P>--- Log_OpenFile.asp ---</P>
<PRE><CODE>&lt;HTML&gt;
&lt;HEAD&gt;&lt;TITLE&gt;&lt;/TITLE&gt;&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;%
LogFile = Request.Form("logfile")
Output = Request.Form("output")
%&gt;
&lt;H3&gt;Convert From W3C Extended Log Format to NCSA Common Log Format&lt;/H3&gt;
&lt;FORM NAME="getlogfilename" METHOD="POST" ACTION="Log_OpenFile.asp"&gt;
Please enter the full path name of a log file to read in %SystemRoot%\system32\LogFiles\*SVC*:&lt;BR&gt;
&lt;input type="TEXT" NAME="logfile" size=70 value=&lt;%=LogFile%&gt;&gt;&lt;BR&gt;
Enter the full path name of a log file to write to:&lt;BR&gt;
&lt;input type="TEXT" NAME="output" size=70 value=&lt;%=Output%&gt;&gt;&lt;BR&gt;
&lt;INPUT TYPE="SUBMIT" VALUE="Submit"&gt;
&lt;/FORM&gt;
&lt;%
''''''''''''''''''''
' Log file formats:
' "NCSA Common Log File Format"
' "Microsoft IIS Log File Format"
' "W3C Extended Log File Format"
'''''''''''''''''''''
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")
If fsoObject.FileExists(LogFile) Then
Set oRead = CreateObject ("MSWC.IISLog")
Set oWrite = CreateObject ("MSWC.IISLog")
oRead.OpenLogFile LogFile, 1, "W3SVC", 1, "W3C Extended Log File Format"
oWrite.OpenLogFile Output, 2, "W3SVC", 1, "NCSA Common Log File Format"
oRead.ReadLogRecord
Do While Not oRead.AtEndOfLog
oWrite.WriteLogRecord oRead
oRead.ReadLogRecord
Loop
oRead.CloseLogFiles 1
oWrite.CloseLogFiles 2
Response.Write "File " &amp; LogFile &amp; "&lt;BR&gt;has been written to " &amp; Output &amp; "&lt;BR&gt;"
ElseIf Not (LogFile = "") Then
Response.Write "ERROR: " &amp; LogFile &amp; " does not exist."
End If
%&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;</CODE></PRE>
<hr class="iis" size="1">
<p align="center"><em><a href="../../../common/colegal.htm">&copy; 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
</BODY>
</HTML>