Set the IIS log type with C#
Set the IIS log type with C#
am 26.06.2007 18:05:54 von freddo411
Hi,
I'm new to C# and IIS. I'm trying to set the logging type.
I'm creating a new website instance like so:
DirectoryEntry site = (DirectoryEntry) root.Invoke ("Create",
"IIsWebServer", siteID);
and I'm setting some options like so before I commitChanges:
site.Invoke ("Put", "ServerComment", webSiteName);
MSDN leads me to believe that:
site.Invoke ("Put", "LogPluginClsid", sClsidNCSA);
will work if I can figure out the value of cClsidNCSA (the built in
NCSA logging).
How do I get this value? Seems to me it would be a constant ...
Cheers
-Fred
Re: Set the IIS log type with C#
am 26.06.2007 20:03:54 von Kristofer Gafvert
You can get it from the metabase. I am not sure if it is a constant or
not, i have never paid attention if it is the same string on all machines.
Anyway, this code snippet shows how to get it from the metabase:
http://msdn2.microsoft.com/en-us/library/ms524877.aspx
--
Regards,
Kristofer Gafvert
http://www.gafvert.info/iis/ - IIS Related Info
freddo411@gmail.com wrote:
>Hi,
>
>I'm new to C# and IIS. I'm trying to set the logging type.
>
>I'm creating a new website instance like so:
>
> DirectoryEntry site = (DirectoryEntry) root.Invoke ("Create",
>"IIsWebServer", siteID);
>
>and I'm setting some options like so before I commitChanges:
>
> site.Invoke ("Put", "ServerComment", webSiteName);
>
>MSDN leads me to believe that:
>
> site.Invoke ("Put", "LogPluginClsid", sClsidNCSA);
>
>will work if I can figure out the value of cClsidNCSA (the built in
>NCSA logging).
>
>How do I get this value? Seems to me it would be a constant ...
>
>
>Cheers
>
>-Fred
Re: Set the IIS log type with C#
am 27.06.2007 23:45:05 von freddo411
Thanks for the pointer. I'm still missing a crucial piece:
IIsLogModule log = new IIsLogModule ("IIS://localhost/Logging/NCSA
Common Log File Format");
site.Invoke ("Put", "LogPluginClsid", log.LogModuleID );
Unfortunately, I need to know the name of the library to include that
contains the definition of IIsLogModule. You'd think that this page
would document what "using" directive was needed for this, but it
doesn't.
http://msdn2.microsoft.com/en-us/library/ms525969.aspx
Building gives this error:
The type or namespace name 'IIsLogModule' could not be found (are you
missing a using directive or an assembly reference?)
On Jun 26, 11:03 am, "Kristofer Gafvert"
wrote:
> You can get it from the metabase. I am not sure if it is a constant or
> not, i have never paid attention if it is the same string on all machines.
>
> Anyway, this code snippet shows how to get it from the metabase:
>
> http://msdn2.microsoft.com/en-us/library/ms524877.aspx
>
> --
> Regards,
> Kristofer Gafverthttp://www.gafvert.info/iis/- IIS Related Info
>
> freddo...@gmail.com wrote:
> >Hi,
>
> >I'm new to C# and IIS. I'm trying to set the logging type.
>
> >I'm creating a new website instance like so:
>
> > DirectoryEntry site = (DirectoryEntry) root.Invoke ("Create",
> >"IIsWebServer", siteID);
>
> >and I'm setting some options like so before I commitChanges:
>
> > site.Invoke ("Put", "ServerComment", webSiteName);
>
> >MSDN leads me to believe that:
>
> > site.Invoke ("Put", "LogPluginClsid", sClsidNCSA);
>
> >will work if I can figure out the value of cClsidNCSA (the built in
> >NCSA logging).
>
> >How do I get this value? Seems to me it would be a constant ...
>
> >Cheers
>
> >-Fred
Re: Set the IIS log type with C#
am 28.06.2007 07:38:09 von Kristofer Gafvert
I don't think there is a .NET class that corresponds to this. You need to
use DirectoryServices. Where have you gotten the class IIsLogModule from?
On IIS 7 you can probably use something from the
Microsoft.Web.Administration namespace (SiteLogFile may be suitable, i
don't have time to check right now).
--
Regards,
Kristofer Gafvert
http://www.gafvert.info/iis/ - IIS Related Info
freddo411@gmail.com wrote:
>Thanks for the pointer. I'm still missing a crucial piece:
>
> IIsLogModule log = new IIsLogModule ("IIS://localhost/Logging/NCSA
>Common Log File Format");
> site.Invoke ("Put", "LogPluginClsid", log.LogModuleID );
>
>Unfortunately, I need to know the name of the library to include that
>contains the definition of IIsLogModule. You'd think that this page
>would document what "using" directive was needed for this, but it
>doesn't.
>http://msdn2.microsoft.com/en-us/library/ms525969.aspx
>
>Building gives this error:
>The type or namespace name 'IIsLogModule' could not be found (are you
>missing a using directive or an assembly reference?)
>
>
>On Jun 26, 11:03 am, "Kristofer Gafvert"
>wrote:
>>You can get it from the metabase. I am not sure if it is a constant or
>>not, i have never paid attention if it is the same string on all machines.
>>
>>Anyway, this code snippet shows how to get it from the metabase:
>>
>>http://msdn2.microsoft.com/en-us/library/ms524877.aspx
>>
>>--
>>Regards,
>>Kristofer Gafverthttp://www.gafvert.info/iis/- IIS Related Info
>>
>>freddo...@gmail.com wrote:
>>>Hi,
>>
>>>I'm new to C# and IIS. I'm trying to set the logging type.
>>
>>>I'm creating a new website instance like so:
>>
>>> DirectoryEntry site = (DirectoryEntry) root.Invoke ("Create",
>>>"IIsWebServer", siteID);
>>
>>>and I'm setting some options like so before I commitChanges:
>>
>>> site.Invoke ("Put", "ServerComment", webSiteName);
>>
>>>MSDN leads me to believe that:
>>
>>> site.Invoke ("Put", "LogPluginClsid", sClsidNCSA);
>>
>>>will work if I can figure out the value of cClsidNCSA (the built in
>>>NCSA logging).
>>
>>>How do I get this value? Seems to me it would be a constant ...
>>
>>>Cheers
>>
>>>-Fred
Re: Set the IIS log type with C#
am 28.06.2007 09:55:19 von David Wang
Hmm... the original sample code never referenced any .Net class named
"IIsLogModule", so I'm not certain why you are trying to instantiate a
non-referenced class...
I suggest you use a tool like ADSUTIL.VBS or write .Net ADSI/WMI
interop C# code to read the value of the CLSID and just put it into
your code.
cscript %SYSTEMDRIVE%\inetpub\AdminScripts\adsutil.vbs enum "logging/
ncsa common log file format"
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
On Jun 27, 2:45 pm, "freddo...@gmail.com" wrote:
> Thanks for the pointer. I'm still missing a crucial piece:
>
> IIsLogModule log = new IIsLogModule ("IIS://localhost/Logging/NCSA
> Common Log File Format");
> site.Invoke ("Put", "LogPluginClsid", log.LogModuleID );
>
> Unfortunately, I need to know the name of the library to include that
> contains the definition of IIsLogModule. You'd think that this page
> would document what "using" directive was needed for this, but it
> doesn't.http://msdn2.microsoft.com/en-us/library/ms525969.as px
>
> Building gives this error:
> The type or namespace name 'IIsLogModule' could not be found (are you
> missing a using directive or an assembly reference?)
>
> On Jun 26, 11:03 am, "Kristofer Gafvert"
> wrote:
>
>
>
> > You can get it from the metabase. I am not sure if it is a constant or
> > not, i have never paid attention if it is the same string on all machines.
>
> > Anyway, this code snippet shows how to get it from the metabase:
>
> >http://msdn2.microsoft.com/en-us/library/ms524877.aspx
>
> > --
> > Regards,
> > Kristofer Gafverthttp://www.gafvert.info/iis/-IIS Related Info
>
> > freddo...@gmail.com wrote:
> > >Hi,
>
> > >I'm new to C# and IIS. I'm trying to set the logging type.
>
> > >I'm creating a new website instance like so:
>
> > > DirectoryEntry site = (DirectoryEntry) root.Invoke ("Create",
> > >"IIsWebServer", siteID);
>
> > >and I'm setting some options like so before I commitChanges:
>
> > > site.Invoke ("Put", "ServerComment", webSiteName);
>
> > >MSDN leads me to believe that:
>
> > > site.Invoke ("Put", "LogPluginClsid", sClsidNCSA);
>
> > >will work if I can figure out the value of cClsidNCSA (the built in
> > >NCSA logging).
>
> > >How do I get this value? Seems to me it would be a constant ...
>
> > >Cheers
>
> > >-Fred- Hide quoted text -
>
> - Show quoted text -