Writing to the EventLog

M

MattC

I have some code that correctly writes to the eventlog on my local machine.
I have installed the application on the Live server and all is not well, no
event log entries.

My development box config is as follows:

Windows XP Pro running IIS 5.1
Web app using integrated auth using a local user account
Account has admin right over machine.
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp


On the Server:
Windows 2003 Server running IIS 6
Web app using integrated auth using a Active Directory account
Account is Domain admin
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp

my code is as follows:

Web.Config
<add key="eventlogname" value="MyApp" />

Global.asax.cs
protected void Application_Error(Object sender, EventArgs e)
{
string _message = "\nError in Path :" + Request.Path ; //Get the path of the
page
_message += "\n\nError Raw Url :" + Request.RawUrl ; //Get the QueryString
along with the Virtual Path
_message += "\n\nRequest from :" + Request.UserHostAddress;
_message += "\n\nError Message :" +
ConquestException.HandleConquestException(Server.GetLastError(), false);
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
//Create a new EventLog object
myLog.Source =
Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set
the name of the Log
myLog.WriteEntry(_message,
System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("~/MyAppError.aspx");
}

I would really appreciate any help you can give me.

MattC
 
S

Scott Allen

Hi MattC:

Try using the following wrapper:

Remotable WMP Player Wrapper for C#
http://www.gotdotnet.com/Community/...mpleGuid=1f2ad011-abf1-4dfd-85c6-49006903e483

This allows you to manipulate and access an out of process media
player instance.

--
Scott
http://www.OdeToCode.com/blogs/scott/

Any ideas, anyone? :S

MattC said:
I have some code that correctly writes to the eventlog on my local machine.
I have installed the application on the Live server and all is not well, no
event log entries.

My development box config is as follows:

Windows XP Pro running IIS 5.1
Web app using integrated auth using a local user account
Account has admin right over machine.
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp


On the Server:
Windows 2003 Server running IIS 6
Web app using integrated auth using a Active Directory account
Account is Domain admin
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp

my code is as follows:

Web.Config
<add key="eventlogname" value="MyApp" />

Global.asax.cs
protected void Application_Error(Object sender, EventArgs e)
{
string _message = "\nError in Path :" + Request.Path ; //Get the path of the
page
_message += "\n\nError Raw Url :" + Request.RawUrl ; //Get the QueryString
along with the Virtual Path
_message += "\n\nRequest from :" + Request.UserHostAddress;
_message += "\n\nError Message :" +
ConquestException.HandleConquestException(Server.GetLastError(), false);
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
//Create a new EventLog object
myLog.Source =
Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set
the name of the Log
myLog.WriteEntry(_message,
System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("~/MyAppError.aspx");
}

I would really appreciate any help you can give me.

MattC
 
S

Scott Allen

Hi again Matt:

Apologies for the last message. Little bit of a mixup in the trusty 10
year old newsreader software here.

It looks as if everything is setup correctly. I was going to do an
experiment to make sure the identity is still impersonated when the
control reaches Application_Error, I can get back to you on that.
9/10 this is related to a permissions issue.

--
Scott
http://www.OdeToCode.com/blogs/scott/

Any ideas, anyone? :S

MattC said:
I have some code that correctly writes to the eventlog on my local machine.
I have installed the application on the Live server and all is not well, no
event log entries.

My development box config is as follows:

Windows XP Pro running IIS 5.1
Web app using integrated auth using a local user account
Account has admin right over machine.
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp


On the Server:
Windows 2003 Server running IIS 6
Web app using integrated auth using a Active Directory account
Account is Domain admin
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp

my code is as follows:

Web.Config
<add key="eventlogname" value="MyApp" />

Global.asax.cs
protected void Application_Error(Object sender, EventArgs e)
{
string _message = "\nError in Path :" + Request.Path ; //Get the path of the
page
_message += "\n\nError Raw Url :" + Request.RawUrl ; //Get the QueryString
along with the Virtual Path
_message += "\n\nRequest from :" + Request.UserHostAddress;
_message += "\n\nError Message :" +
ConquestException.HandleConquestException(Server.GetLastError(), false);
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
//Create a new EventLog object
myLog.Source =
Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set
the name of the Log
myLog.WriteEntry(_message,
System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("~/MyAppError.aspx");
}

I would really appreciate any help you can give me.

MattC
 
M

MattC

Thanks Scott, I know its slightly off topic but what permission level is
require by the impersonating user on Windows 2003 Svr to write to the event
log.

Also why does my failure to write not cause AST.NET to write and event
stating the failure?

TIA

MattC
Scott Allen said:
Hi again Matt:

Apologies for the last message. Little bit of a mixup in the trusty 10
year old newsreader software here.

It looks as if everything is setup correctly. I was going to do an
experiment to make sure the identity is still impersonated when the
control reaches Application_Error, I can get back to you on that.
9/10 this is related to a permissions issue.

--
Scott
http://www.OdeToCode.com/blogs/scott/

Any ideas, anyone? :S

MattC said:
I have some code that correctly writes to the eventlog on my local machine.
I have installed the application on the Live server and all is not
well,
no
event log entries.

My development box config is as follows:

Windows XP Pro running IIS 5.1
Web app using integrated auth using a local user account
Account has admin right over machine.
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp


On the Server:
Windows 2003 Server running IIS 6
Web app using integrated auth using a Active Directory account
Account is Domain admin
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp

my code is as follows:

Web.Config
<add key="eventlogname" value="MyApp" />

Global.asax.cs
protected void Application_Error(Object sender, EventArgs e)
{
string _message = "\nError in Path :" + Request.Path ; //Get the path
of
the
page
_message += "\n\nError Raw Url :" + Request.RawUrl ; //Get the QueryString
along with the Virtual Path
_message += "\n\nRequest from :" + Request.UserHostAddress;
_message += "\n\nError Message :" +
ConquestException.HandleConquestException(Server.GetLastError(), false);
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
//Create a new EventLog object
myLog.Source =
Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set
the name of the Log
myLog.WriteEntry(_message,
System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("~/MyAppError.aspx");
}

I would really appreciate any help you can give me.

MattC
 
G

Guest

We are experiencing the same problem. I would like to measure the efficiency
of this forum by seeing a reply even if it took more than 2 business days as
promised...

TIA -a large customer of yours

MattC said:
Thanks Scott, I know its slightly off topic but what permission level is
require by the impersonating user on Windows 2003 Svr to write to the event
log.

Also why does my failure to write not cause AST.NET to write and event
stating the failure?

TIA

MattC
Scott Allen said:
Hi again Matt:

Apologies for the last message. Little bit of a mixup in the trusty 10
year old newsreader software here.

It looks as if everything is setup correctly. I was going to do an
experiment to make sure the identity is still impersonated when the
control reaches Application_Error, I can get back to you on that.
9/10 this is related to a permissions issue.

--
Scott
http://www.OdeToCode.com/blogs/scott/

Any ideas, anyone? :S

I have some code that correctly writes to the eventlog on my local
machine.
I have installed the application on the Live server and all is not well,
no
event log entries.

My development box config is as follows:

Windows XP Pro running IIS 5.1
Web app using integrated auth using a local user account
Account has admin right over machine.
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp


On the Server:
Windows 2003 Server running IIS 6
Web app using integrated auth using a Active Directory account
Account is Domain admin
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp

my code is as follows:

Web.Config
<add key="eventlogname" value="MyApp" />

Global.asax.cs
protected void Application_Error(Object sender, EventArgs e)
{
string _message = "\nError in Path :" + Request.Path ; //Get the path of
the
page
_message += "\n\nError Raw Url :" + Request.RawUrl ; //Get the QueryString
along with the Virtual Path
_message += "\n\nRequest from :" + Request.UserHostAddress;
_message += "\n\nError Message :" +
ConquestException.HandleConquestException(Server.GetLastError(), false);
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
//Create a new EventLog object
myLog.Source =
Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set
the name of the Log
myLog.WriteEntry(_message,
System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("~/MyAppError.aspx");
}

I would really appreciate any help you can give me.

MattC
 
S

Scott Allen

I can tell you what has been working for me, which is to use REGEDT32
and navigating to HKEY_LOCAL_MACHINE\SYSTEM then
CurrentControlSet\Services\Eventlog. At this point REGEDT32 has a
Security menu you can click on to assign permissions. Giving the
ASPNET process account full control will allow a web app to write to
the event logs (try to be a little more granular than the entire event
log though).

The problem with impersonation is that you'll need to add the
impersonation accounts here, unless you RevertToSelf before writing.

--
Scott
http://www.OdeToCode.com/blogs/scott/


We are experiencing the same problem. I would like to measure the efficiency
of this forum by seeing a reply even if it took more than 2 business days as
promised...

TIA -a large customer of yours

MattC said:
Thanks Scott, I know its slightly off topic but what permission level is
require by the impersonating user on Windows 2003 Svr to write to the event
log.

Also why does my failure to write not cause AST.NET to write and event
stating the failure?

TIA

MattC
Scott Allen said:
Hi again Matt:

Apologies for the last message. Little bit of a mixup in the trusty 10
year old newsreader software here.

It looks as if everything is setup correctly. I was going to do an
experiment to make sure the identity is still impersonated when the
control reaches Application_Error, I can get back to you on that.
9/10 this is related to a permissions issue.

--
Scott
http://www.OdeToCode.com/blogs/scott/


Any ideas, anyone? :S

I have some code that correctly writes to the eventlog on my local
machine.
I have installed the application on the Live server and all is not well,
no
event log entries.

My development box config is as follows:

Windows XP Pro running IIS 5.1
Web app using integrated auth using a local user account
Account has admin right over machine.
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp


On the Server:
Windows 2003 Server running IIS 6
Web app using integrated auth using a Active Directory account
Account is Domain admin
Entry has been placed in registry in
\HKLM\System\CurrentControlSet\Services\EventLog\Application\MyApp

my code is as follows:

Web.Config
<add key="eventlogname" value="MyApp" />

Global.asax.cs
protected void Application_Error(Object sender, EventArgs e)
{
string _message = "\nError in Path :" + Request.Path ; //Get the path of
the
page
_message += "\n\nError Raw Url :" + Request.RawUrl ; //Get the QueryString
along with the Virtual Path
_message += "\n\nRequest from :" + Request.UserHostAddress;
_message += "\n\nError Message :" +
ConquestException.HandleConquestException(Server.GetLastError(), false);
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
//Create a new EventLog object
myLog.Source =
Convert.ToString(ConfigurationSettings.AppSettings["eventlogname"]); //Set
the name of the Log
myLog.WriteEntry(_message,
System.Diagnostics.EventLogEntryType.Error);//Write the log
Server.Transfer("~/MyAppError.aspx");
}

I would really appreciate any help you can give me.

MattC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top