473,545 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing Exceptions to the Application Log

Hi there

I'm trying to find the correct way to write exceptions to the Application
log using Vb.Net.

I've done a fair bit of Googleing and although this gets plenty of mentions
and that this is apparently the correct way forward nobody offers a solution
as to how it is actually done.

I gather that code like:

Try
'my code goes here
Catch ex As Exception
My.Log.WriteExc eption(ex)
End Try

Will write the exception to a listener but there is no mention of how a
listener is set up on a web App and how this is configured to write to the
Application Log (Security permissions etc)

Plenty of the on line info suggest a Registry hack but this doesnt seem
appropiatte.

PS. I do find it ironic that if i dont catch the exception it gets written
to the log by default.

Thanks for your help.

Martyn


--
Regards

Martyn Fewtrell
Jul 30 '06 #1
12 6037
Don't bother writing to the Application log.

Peter Bromberg outlines a much better way to log exceptions in this article :

http://www.eggheadcafe.com/articles/20030816.asp

Read the article...and download his sampl code at :
http://www.eggheadcafe.com/articles/20030816.zip


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espańol : http://asp.net.do/foros/
=============== =============== =====
"Martyn Fewtrell" <mf*******@news group.nospamwro te in message
news:69******** *************** ***********@mic rosoft.com...
Hi there

I'm trying to find the correct way to write exceptions to the Application
log using Vb.Net.

I've done a fair bit of Googleing and although this gets plenty of mentions
and that this is apparently the correct way forward nobody offers a solution
as to how it is actually done.

I gather that code like:

Try
'my code goes here
Catch ex As Exception
My.Log.WriteExc eption(ex)
End Try

Will write the exception to a listener but there is no mention of how a
listener is set up on a web App and how this is configured to write to the
Application Log (Security permissions etc)

Plenty of the on line info suggest a Registry hack but this doesnt seem
appropiatte.

PS. I do find it ironic that if i dont catch the exception it gets written
to the log by default.

Thanks for your help.

Martyn


--
Regards

Martyn Fewtrell

Jul 30 '06 #2
Thanks to Juan for the mention, actually I have an even more "Generic"
implementation of that here:

http://www.eggheadcafe.com/articles/20060531.asp

However, if you really want to write to the Event Log, take a look at the
System.Diagnost ics Namepace. There are static methods there for this.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Martyn Fewtrell" wrote:
Hi there

I'm trying to find the correct way to write exceptions to the Application
log using Vb.Net.

I've done a fair bit of Googleing and although this gets plenty of mentions
and that this is apparently the correct way forward nobody offers a solution
as to how it is actually done.

I gather that code like:

Try
'my code goes here
Catch ex As Exception
My.Log.WriteExc eption(ex)
End Try

Will write the exception to a listener but there is no mention of how a
listener is set up on a web App and how this is configured to write to the
Application Log (Security permissions etc)

Plenty of the on line info suggest a Registry hack but this doesnt seem
appropiatte.

PS. I do find it ironic that if i dont catch the exception it gets written
to the log by default.

Thanks for your help.

Martyn


--
Regards

Martyn Fewtrell
Jul 30 '06 #3
Ahh...
Thanks for that update, Peter.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espańol : http://asp.net.do/foros/
=============== =============== =====
"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com wrote in message
news:6F******** *************** ***********@mic rosoft.com...
Thanks to Juan for the mention, actually I have an even more "Generic"
implementation of that here:

http://www.eggheadcafe.com/articles/20060531.asp

However, if you really want to write to the Event Log, take a look at the
System.Diagnost ics Namepace. There are static methods there for this.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Martyn Fewtrell" wrote:
>Hi there

I'm trying to find the correct way to write exceptions to the Application
log using Vb.Net.

I've done a fair bit of Googleing and although this gets plenty of mentions
and that this is apparently the correct way forward nobody offers a solution
as to how it is actually done.

I gather that code like:

Try
'my code goes here
Catch ex As Exception
My.Log.WriteExc eption(ex)
End Try

Will write the exception to a listener but there is no mention of how a
listener is set up on a web App and how this is configured to write to the
Application Log (Security permissions etc)

Plenty of the on line info suggest a Registry hack but this doesnt seem
appropiatte.

PS. I do find it ironic that if i dont catch the exception it gets written
to the log by default.

Thanks for your help.

Martyn

Jul 31 '06 #4
Thanks for Juan and Peter's informative resource.

Hi Martyn,

As for using the "My.Log" object (VB.NET specific ) to log information in
ASP.NET 2.0 web application, you need to do the following configuration:

1. First register a text file listener in the web.config if you want to
write the trace log into text file. e.g.

===========
<system.diagnos tics>
............... ...
<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>

</sharedListeners >
</system.diagnost ics>
===========

Be careful that we should not use the
"Microsoft.Visu alBasic.Logging .FileLogTraceLi stener" class here because the
"Microsoft.Visu alBasic.Logging .FileLogTraceLi stener" class will always look
for a path in the current user's Local application directory( and this path
doesn't exist for the ASP.NET service account, "Network Service" or
"machine\ASPNET "). Therefore, we use the
System.Diagnost ics.TextWriterT raceListener class instead(if you want, you
can use some other XML Trace Listeners under that namespace too)
2. Add a switch under the <switchessectio n like:

===========
<system.diagnos tics >
.............
<switches >
<add name="DefaultSw itch" value="Verbose" />
</switches>
..............
============

This is used to control what level information will be logged(and other
level information will be ignored)

#Configuring Trace Switches
http://msdn.microsoft.com/library/en...urationoftrace
switches.asp?fr ame=true
3. After add the Listener and Switch elements, we need to add the "Source"
element for our My.Log object.
=============== ===
<system.diagnos tics >
............... ..............
<sources >
<source name="DefaultSo urce" switchName="Def aultSwitch">
<listeners>
<add name="FileLogLi stener"/>
</listeners>
</source>

............... ...
=============== ==

This "DefaultSou rce" will be used by our VB.NET My.Log object and we
reference the "FileLogListene r" configured previously.

In addition, we should add the <trace autoflush="true " ></traceto make
the runtime immediately write out trace after we call My.Log.Writexxx x
So the complete configuration section will look like below:
=============== =============== =
<system.diagnos tics >
<trace autoflush="true " ></trace>
<sources >
<source name="DefaultSo urce" switchName="Def aultSwitch">
<listeners>
<add name="FileLogLi stener"/>

</listeners>
</source>
</sources>

<switches >
<add name="DefaultSw itch" value="Verbose" />
</switches>

<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>
</sharedListeners >
</system.diagnost ics>
=============== =============== =====

You can put it in your application's web.config file and use My.Log object
to write trace log. BTW, make sure your ASP.NET servcie identity has
sufficient permission to modify log files in the certain path we specified
in the above <sharedListener s>. like:

==============
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>
==============

BTW, the following msdn document describes most information about
configuration of My.Log object( and add custom listeners for it). However,
there is one error in it. We should not use the
"Microsoft.Visu alBasic.Logging .FileLogTraceLi stener" class for ASP.NET
application as I mentioned above, just take care of this.

#Walkthrough: Changing Where My.Application. Log Writes Information
http://msdn2.microsoft.com/en-us/library/5cz98azz.aspx

If you have anything unclear or any further questions, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 31 '06 #5
Thanks for all the responses, I'll take a look through and see what suits the
situation best.

I have to say the solution for "Dummies" sounds appealing!
--
Regards

Martyn Fewtrell
"Steven Cheng[MSFT]" wrote:
Thanks for Juan and Peter's informative resource.

Hi Martyn,

As for using the "My.Log" object (VB.NET specific ) to log information in
ASP.NET 2.0 web application, you need to do the following configuration:

1. First register a text file listener in the web.config if you want to
write the trace log into text file. e.g.

===========
<system.diagnos tics>
............... ...
<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>

</sharedListeners >
</system.diagnost ics>
===========

Be careful that we should not use the
"Microsoft.Visu alBasic.Logging .FileLogTraceLi stener" class here because the
"Microsoft.Visu alBasic.Logging .FileLogTraceLi stener" class will always look
for a path in the current user's Local application directory( and this path
doesn't exist for the ASP.NET service account, "Network Service" or
"machine\ASPNET "). Therefore, we use the
System.Diagnost ics.TextWriterT raceListener class instead(if you want, you
can use some other XML Trace Listeners under that namespace too)
2. Add a switch under the <switchessectio n like:

===========
<system.diagnos tics >
.............
<switches >
<add name="DefaultSw itch" value="Verbose" />
</switches>
..............
============

This is used to control what level information will be logged(and other
level information will be ignored)

#Configuring Trace Switches
http://msdn.microsoft.com/library/en...urationoftrace
switches.asp?fr ame=true
3. After add the Listener and Switch elements, we need to add the "Source"
element for our My.Log object.
=============== ===
<system.diagnos tics >
............... ..............
<sources >
<source name="DefaultSo urce" switchName="Def aultSwitch">
<listeners>
<add name="FileLogLi stener"/>
</listeners>
</source>

............... ...
=============== ==

This "DefaultSou rce" will be used by our VB.NET My.Log object and we
reference the "FileLogListene r" configured previously.

In addition, we should add the <trace autoflush="true " ></traceto make
the runtime immediately write out trace after we call My.Log.Writexxx x
So the complete configuration section will look like below:
=============== =============== =
<system.diagnos tics >
<trace autoflush="true " ></trace>
<sources >
<source name="DefaultSo urce" switchName="Def aultSwitch">
<listeners>
<add name="FileLogLi stener"/>

</listeners>
</source>
</sources>

<switches >
<add name="DefaultSw itch" value="Verbose" />
</switches>

<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>
</sharedListeners >
</system.diagnost ics>
=============== =============== =====

You can put it in your application's web.config file and use My.Log object
to write trace log. BTW, make sure your ASP.NET servcie identity has
sufficient permission to modify log files in the certain path we specified
in the above <sharedListener s>. like:

==============
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>
==============

BTW, the following msdn document describes most information about
configuration of My.Log object( and add custom listeners for it). However,
there is one error in it. We should not use the
"Microsoft.Visu alBasic.Logging .FileLogTraceLi stener" class for ASP.NET
application as I mentioned above, just take care of this.

#Walkthrough: Changing Where My.Application. Log Writes Information
http://msdn2.microsoft.com/en-us/library/5cz98azz.aspx

If you have anything unclear or any further questions, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 31 '06 #6
Once again thanks for all the replies.

Steven

The information you have sent me is great apart from the fact that I do
actually want to write the information to the application log. I appreciate
the principal follows through the same logic. Therefore I assume the line:

<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>

</sharedListeners >

needs to be something different? Something like:

<sharedListener s>
<add name="Applicati onLogListener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "something different in here?"/>

</sharedListeners >

Note the "Something different in here?"

After this I think the real issue is the comment:

"make sure your ASP.NET service identity has sufficient permission to modify
log files in the certain path we specified"

which is fine for a folder on the local drive where I can give access
(Read/Write etc) for the Network Service account but what I don’t know is
what user writes does which account need to write to the Application Log and
where do I set this.

Again I assume this is the Network Service account on ASP.Net 2.0 with Win
Server 2003 (IIS6) but what writes does it need and how are they set?

Thanks again for your comprehensive answer.

--
Regards

Martyn Fewtrell
"Steven Cheng[MSFT]" wrote:
Thanks for Juan and Peter's informative resource.

Hi Martyn,

As for using the "My.Log" object (VB.NET specific ) to log information in
ASP.NET 2.0 web application, you need to do the following configuration:

1. First register a text file listener in the web.config if you want to
write the trace log into text file. e.g.

===========
<system.diagnos tics>
............... ...
<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>

</sharedListeners >
</system.diagnost ics>
===========

Be careful that we should not use the
"Microsoft.Visu alBasic.Logging .FileLogTraceLi stener" class here because the
"Microsoft.Visu alBasic.Logging .FileLogTraceLi stener" class will always look
for a path in the current user's Local application directory( and this path
doesn't exist for the ASP.NET service account, "Network Service" or
"machine\ASPNET "). Therefore, we use the
System.Diagnost ics.TextWriterT raceListener class instead(if you want, you
can use some other XML Trace Listeners under that namespace too)
2. Add a switch under the <switchessectio n like:

===========
<system.diagnos tics >
.............
<switches >
<add name="DefaultSw itch" value="Verbose" />
</switches>
..............
============

This is used to control what level information will be logged(and other
level information will be ignored)

#Configuring Trace Switches
http://msdn.microsoft.com/library/en...urationoftrace
switches.asp?fr ame=true
3. After add the Listener and Switch elements, we need to add the "Source"
element for our My.Log object.
=============== ===
<system.diagnos tics >
............... ..............
<sources >
<source name="DefaultSo urce" switchName="Def aultSwitch">
<listeners>
<add name="FileLogLi stener"/>
</listeners>
</source>

............... ...
=============== ==

This "DefaultSou rce" will be used by our VB.NET My.Log object and we
reference the "FileLogListene r" configured previously.

In addition, we should add the <trace autoflush="true " ></traceto make
the runtime immediately write out trace after we call My.Log.Writexxx x
So the complete configuration section will look like below:
=============== =============== =
<system.diagnos tics >
<trace autoflush="true " ></trace>
<sources >
<source name="DefaultSo urce" switchName="Def aultSwitch">
<listeners>
<add name="FileLogLi stener"/>

</listeners>
</source>
</sources>

<switches >
<add name="DefaultSw itch" value="Verbose" />
</switches>

<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>
</sharedListeners >
</system.diagnost ics>
=============== =============== =====

You can put it in your application's web.config file and use My.Log object
to write trace log. BTW, make sure your ASP.NET servcie identity has
sufficient permission to modify log files in the certain path we specified
in the above <sharedListener s>. like:

==============
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>
==============

BTW, the following msdn document describes most information about
configuration of My.Log object( and add custom listeners for it). However,
there is one error in it. We should not use the
"Microsoft.Visu alBasic.Logging .FileLogTraceLi stener" class for ASP.NET
application as I mentioned above, just take care of this.

#Walkthrough: Changing Where My.Application. Log Writes Information
http://msdn2.microsoft.com/en-us/library/5cz98azz.aspx

If you have anything unclear or any further questions, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 31 '06 #7
Hi Martyn,

Just found that I've missed the point that you're wantting to write the
error message into "Event Log" (I previously think that the "Applicatio n
Log" you mentioned means a custom application log file). If so, you should
replace the text file listener with an EventLog Trace Listener class.
The "System.Diagnos tics.EventLogTr aceListener" class is a built-in class
which is capable of this. Here is a modified configuratino section that use
both text file and eventlog trace listener:

=============== =============== =
<system.diagnos tics >
<trace autoflush="true " ></trace>
<sources >
<source name="DefaultSo urce" switchName="Def aultSwitch">
<listeners>
<add name="FileLogLi stener"/>
<add name="EventLogL istener" />
</listeners>
</source>
</sources>

<switches >
<add name="DefaultSw itch" value="Verbose" />
</switches>

<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>

<add name="EventLogL istener"
type="System.Di agnostics.Event LogTraceListene r,
System, Version=2.0.0.0 ,
Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
initializeData= "Applicatio n"/>
</sharedListeners >
</system.diagnost ics>
=============== =============== =====

also, take care of the "initializeData " attribute in the eventlog listener
configuration element.

=============
<add name="EventLogL istener"
............... ..............
initializeData= "Applicatio n"/>
</sharedListeners >
=============== ======

Here I set it to "Applicatio n" because ASP.NET worker process identity(such
as Network Service) can only write to the "Applicatio n" source in the
eventlog, if you change to other value, that means you would write to a
"Custom Event Source". Then you may get "Access Denied" error, in such
cases, you need to grant the ASP.NET process identity sufficient permission
to write into that custom event source (of course you need to create the
custom event source first if it doesn't exist originally).

Hope this also helps. If you have anything unclear, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Jul 31 '06 #8
Thanks Steven

I have managed to write to a text file on the hard drive based on your
earlier post so that bit worked fine. I'll try these later modifications and
get back to you if I get stuck.

Once again thanks!
--
Regards

Martyn Fewtrell
"Steven Cheng[MSFT]" wrote:
Hi Martyn,

Just found that I've missed the point that you're wantting to write the
error message into "Event Log" (I previously think that the "Applicatio n
Log" you mentioned means a custom application log file). If so, you should
replace the text file listener with an EventLog Trace Listener class.
The "System.Diagnos tics.EventLogTr aceListener" class is a built-in class
which is capable of this. Here is a modified configuratino section that use
both text file and eventlog trace listener:

=============== =============== =
<system.diagnos tics >
<trace autoflush="true " ></trace>
<sources >
<source name="DefaultSo urce" switchName="Def aultSwitch">
<listeners>
<add name="FileLogLi stener"/>
<add name="EventLogL istener" />
</listeners>
</source>
</sources>

<switches >
<add name="DefaultSw itch" value="Verbose" />
</switches>

<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>

<add name="EventLogL istener"
type="System.Di agnostics.Event LogTraceListene r,
System, Version=2.0.0.0 ,
Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
initializeData= "Applicatio n"/>
</sharedListeners >
</system.diagnost ics>
=============== =============== =====

also, take care of the "initializeData " attribute in the eventlog listener
configuration element.

=============
<add name="EventLogL istener"
............... ..............
initializeData= "Applicatio n"/>
</sharedListeners >
=============== ======

Here I set it to "Applicatio n" because ASP.NET worker process identity(such
as Network Service) can only write to the "Applicatio n" source in the
eventlog, if you change to other value, that means you would write to a
"Custom Event Source". Then you may get "Access Denied" error, in such
cases, you need to grant the ASP.NET process identity sufficient permission
to write into that custom event source (of course you need to create the
custom event source first if it doesn't exist originally).

Hope this also helps. If you have anything unclear, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Jul 31 '06 #9
Steven

Thats great my Test Application works fine so I can now transfer it across
to the real project. I guess I need myself a good book on Web Config files
and what can and can't be added etc.

--
Regards

Martyn Fewtrell
"Steven Cheng[MSFT]" wrote:
Hi Martyn,

Just found that I've missed the point that you're wantting to write the
error message into "Event Log" (I previously think that the "Applicatio n
Log" you mentioned means a custom application log file). If so, you should
replace the text file listener with an EventLog Trace Listener class.
The "System.Diagnos tics.EventLogTr aceListener" class is a built-in class
which is capable of this. Here is a modified configuratino section that use
both text file and eventlog trace listener:

=============== =============== =
<system.diagnos tics >
<trace autoflush="true " ></trace>
<sources >
<source name="DefaultSo urce" switchName="Def aultSwitch">
<listeners>
<add name="FileLogLi stener"/>
<add name="EventLogL istener" />
</listeners>
</source>
</sources>

<switches >
<add name="DefaultSw itch" value="Verbose" />
</switches>

<sharedListener s>
<add name="FileLogLi stener"
type="System.Di agnostics.TextW riterTraceListe ner"
initializeData= "d:\temp\web_ap p_log.txt"/>

<add name="EventLogL istener"
type="System.Di agnostics.Event LogTraceListene r,
System, Version=2.0.0.0 ,
Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
initializeData= "Applicatio n"/>
</sharedListeners >
</system.diagnost ics>
=============== =============== =====

also, take care of the "initializeData " attribute in the eventlog listener
configuration element.

=============
<add name="EventLogL istener"
............... ..............
initializeData= "Applicatio n"/>
</sharedListeners >
=============== ======

Here I set it to "Applicatio n" because ASP.NET worker process identity(such
as Network Service) can only write to the "Applicatio n" source in the
eventlog, if you change to other value, that means you would write to a
"Custom Event Source". Then you may get "Access Denied" error, in such
cases, you need to grant the ASP.NET process identity sufficient permission
to write into that custom event source (of course you need to create the
custom event source first if it doesn't exist originally).

Hope this also helps. If you have anything unclear, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Jul 31 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1053
by: Ehab Teima | last post by:
Hello, I have built a server application. It's multithreaded, and everything works fine so far. I have only one issue with catching exceptions after I read the documentation but I can't find any problems yet. I'm catching all errors throughout the code into a function and I write the traceback to the server log as well as the screen. That's...
24
2469
by: mag31 | last post by:
Is there any way to find out if a particular .net function will throw an exception without first generating the exception? I am using structured exception handling i.e. try catch finally blocks with a top level catch all for Exception. However, I would like to be able to catch most .net exceptions when they are generated. I would then be...
11
1447
by: C# Learner | last post by:
What type of exception should I throw when my code detects that a connection has dropped (i.e. NetworkStream.Read() returns 0)? Should I just throw a SocketException or should I create my own class and throw that instead -- what would be the usual practise in a case like this?
6
2818
by: RepStat | last post by:
I've read that it is best not to use exceptions willy-nilly for stupid purposes as they can be a major performance hit if they are thrown. But is it a performance hit to use a try..catch..finally block, just in case there might be an exception? i.e. is it ok performance-wise to pepper pieces of code with try..catch..finally blocks that must be...
16
2146
by: Einar Hřst | last post by:
Hi, I'm getting into the Trace-functionality in .NET, using it to provide some much-needed logging across dlls in the project we're working on. However, being a newbie, I'm wondering if some more experienced loggers can provide me with some ideas as to how to log in a simple yet flexible manner. For instance, I'd like the code to be as...
4
1839
by: Steve | last post by:
I have read a couple articles online, read my Jesse Liberty book but I am still confused as to just what the best practices are for using exceptions. I keep changing how I'm working with them and it has now, after 15k lines of code resulted in a royal mess! It's my hope to ask some specific questions with scenario examples and that some of...
6
3387
by: JeffDotNet | last post by:
Writing to a registered source in the Application event log I have an asp.net framework 2.0 app that I created on a winxp machine and now I am deploying it to IIS6 on a win server2003 machine. This application has to write to the application event log. After deployment of the application I have verified that my source “MySource”...
6
2036
by: Liming | last post by:
Hi, In a typical 3 tier model (view layer, busines layer and data access layer) where do you handle your exceptions? do you let it buble up all the way to the .aspx pages or do you handle it in your business layer and/or data access layer? suppose in my data access layer, I provide try and catch, log the exception and re-throw it back...
0
7409
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7921
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1900
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.