473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Writing to a registered source in the Application event log with I

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” exists in the Application event log. I then wrote some text to
the event source in a forms app and verified that it showed up in the
Application event log.

Since I don’t require my Application to create the event log source I don’t
believe I should have to give Network Service additional rights. I have
spent the day reading posts about writing to the event log to no avail.

Thanks in advance

-Jeff
My application throws this exception when it hits the line requiring it to
write to the event log :

Access to the path 'C:\Documents and Settings\Default User\Application
Data\Microsoft Corporation\Internet Information Services\6.0.3790.1830' is
denied.

//--------- Writing to the event log

My.Log.WriteEntry(“Success I have written to the event log”)
// ----------- Excerpt from my webConfig file ----------------

<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for
My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event
Log -->
<add name="EventLog"/>
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information"/>
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceLi stener,
Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME (now
'default') with the name of your application to write to the Application
Event Log -->
<add name="EventLog" type="System.Diagnostics.EventLogTraceListener"
initializeData="MySource"/>
</sharedListeners>
</system.diagnostics>

Jul 12 '06 #1
6 3358
Hi Jeff,

Thank you for your post.

Based on my understanding, you're having problem writing log in ASP.NET and
IIS 6.0.

After reviewed your web.config and the source code, I've been able to
reproduce the problem on my test environment. I also found that the problem
is not related to the event log part, you're doing right that create the
event source first. The problem is actually related to the FileLog part.

FileLogTraceListener.Location default to LocalUserApplicationDirectory.

You can change it to Custom and use the CustomLocation property to specify
the log file location. Just make sure you give the NETWORK SERVICE account
required ACL to the location.

<add name="FileLogListener"
type="Microsoft.VisualBasic.Logging.FileLogTraceLi stener,
Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
initializeData="FileLogListenerWriter"
location="Custom"
customlocation="c:\temp\" />

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Jul 13 '06 #2
Walter thanks for your response!

I am still unable to get this to work.

I notice that this custom log writes to a file. Does this mean having the
network service account write to the application log is not recommended? I
would like my log to be visible from the Computer Management Snap-in.

From you advice and 2 msdn articles:
http://msdn2.microsoft.com/en-us/library/yhx0xwks.aspx
http://msdn2.microsoft.com/en-us/library/5cz98azz.aspx

This is the new version of the web.config file excerpt

<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for
My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>

<!-- Uncomment the below section to write to the Application Event Log -->
<!—
If writing to the event log is causing the problem I don’t believe we want
this listener to receive log messages anymore.

<add name="EventLog"/>
-->
<add name="FileLogListener" />
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information"/>
</switches>
<sharedListeners>

<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceLi stener,
Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME (now
'APPLICATION_NAME') with the name of your application to write to the
Application Event Log -->

<!--
<add name="EventLog" type="System.Diagnostics.EventLogTraceListener"
initializeData="MySource"/>
-->

<add name="FileLogListener"
type="Microsoft.VisualBasic.Logging.FileLogTraceLi stener,
Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" initializeData="FileLogListenerWriter"
location="Custom" customlocation="C:\LogFiles\" />

</sharedListeners>
</system.diagnostics>

On my laptop running XP

My.Log.WriteEntry("Testing")

Creates a log file (“WebDev.WebServer.log “) in the correct location
(“C:\LogFiles\”) as expected however the log file remains empty without any
exceptions being thrown. So none of the messages are being recorded.
On the Win2003 Server

I still get the same error message:

"Access to the path 'C:\Documents and Settings\Default User\Application
Data\Microsoft Corporation\Internet Information Services\6.0.3790.1830' is
denied."

Note: I have given “Network Service” Full Control of “C:\LogFiles\”

And on the XP machine my web.config provided the correct information to
create the “WebDev.WebServer.log”.

I don’t know what is causing it to look in that folder. I have also tried
commenting out the FileLog listner entry ( <add name="FileLog"/) and the
sharedListner entry (
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceLi stener,
Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
) and I still get the same error.

Where you able to get this to work? Could you send me your webconfig file?
Thanks,

Jeff

Jul 13 '06 #3
Hi Jeff,

Thank you for your update.

I'm sorry that I didn't fully test the code in my last mail. I've now been
able to reproduce the issue you've described and found that it's a known
issue of FileLogTraceListener.

#Issues When Using Microsoft Visual Studio 2005
http://msdn.microsoft.com/vstudio/su...s/default.aspx
Search for section 1.43 "My.Application.Log.WriteEntry may throw an
exception if user does not have File I/O permission".

I'm sorry for the inconvenience of this issue.

Since you mentioned that you want to your log to be visible from the
Computer Management snap-in, I suppose you're referring to the Event Log
viewer in Computer Management snap-in. You only need the EventLog listener
to do that.

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Jul 14 '06 #4
Hi Jeff,

I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.

Have a great day!

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Jul 18 '06 #5
I haven't seen a good answer to this question, and this solution
probably isn't a good workaround, but it worked for me. If someone has
the fix please post.

After a blunder of instantiating
Microsoft.VisualBasic.Logging.FileLogTraceListener and trying to work
with that, I noticed a recurring error about access denied to a certain
path.

What finally seemed to work for me was to create the following
directory structure where C is the drive where the user profiles are
stored.

C:\Documents and Settings\Default User\Application Data\Microsoft
Corporation\Internet Information Services\6.0.3790.1830

Then on my page, I assure the log file writer points to my custom log
....

With My.Log.DefaultFileLogWriter
.Append = True
.AutoFlush = True
.BaseFileName = "MyApp"
.CustomLocation = "C:\Examples\MyApp\Logs"
.Location = Logging.LogFileLocation.Custom
.LogFileCreationSchedule =
Logging.LogFileCreationScheduleOption.Daily
End With

Then I write

My.Log.WriteEntry(Now.ToString + ": " + msg + vbCrLf)

Walter Wang [MSFT] wrote:
Hi Jeff,

I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.

Have a great day!

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jul 24 '06 #6
Walter,

Sorry for the delay in getting back to you. I've been on vacation.

All I had to do was comment out the <add name="FileLog"/>
This was what kept throwing the exception. Its placement in the webcofig
file made me think it was necceary to do any logging. However it is not
necessary to write to the event log.

I tried the logging to file but wasn't able to get it to work consistently.
But this was not my original goal.

Thanks,

Jeff

"Walter Wang [MSFT]" wrote:
Hi Jeff,

I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.

Have a great day!

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Aug 1 '06 #7

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

Similar topics

1
by: Craig Hurcum | last post by:
Hi, I'm trying to log a formatted event to the Windows NT Security Event Log but I am having problems. I can get events into the log, but always unformatted with the data appearing in the...
0
by: Jacob Colding | last post by:
Hello, I have created a a logging mechanism, that writes mesages to a custom event log. On each check it verifies whether the requested source is registered to the "IPS" log. If not, it changes...
2
by: Scott Vercuski | last post by:
Everyone, I'm having trouble writing an event to the event log. Here is the chunk of code I currently have. ----------------------------------------------------------------------- Private...
2
by: MattB | last post by:
I'm writing some code to log errors in a web app (vb/asp.net). I found a straightforward-looking example here: http://www.c-sharpcorner.com/Code/2002/May/CustomErrorHandlingASPNEt.asp But mine...
0
by: Tom Wingert | last post by:
Hi, I am having a problem with getting My.Log.WriteException to write to the Event Log in ASP.Net 2.0 with a web service. When an error occurs, My.Log.WriteException doesn't log anything to the...
6
by: rekaeps | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Also, in the same scenario,...
12
by: Martyn Fewtrell | last post by:
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...
10
by: David Thielen | last post by:
Hi; I am trying to write to the event log using: public const string EVENT_LOG_NAME = "Windward Portal"; if (!EventLog.SourceExists(EVENT_LOG_NAME)) EventLog.CreateEventSource(EVENT_LOG_NAME,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

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.