Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Writing to a registered source in the Application event log with I

Reply
Thread Tools

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

 
 
=?Utf-8?B?SmVmZkRvdE5ldA==?=
Guest
Posts: n/a
 
      07-12-2006
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>

 
Reply With Quote
 
 
 
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      07-13-2006
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 ((E-Mail Removed), 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.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmVmZkRvdE5ldA==?=
Guest
Posts: n/a
 
      07-13-2006
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





 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      07-14-2006
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 ((E-Mail Removed), 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.

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      07-18-2006
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 ((E-Mail Removed), 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.

 
Reply With Quote
 
cory
Guest
Posts: n/a
 
      07-24-2006
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 ((E-Mail Removed), 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.


 
Reply With Quote
 
=?Utf-8?B?SmVmZkRvdE5ldA==?=
Guest
Posts: n/a
 
      08-01-2006
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 ((E-Mail Removed), 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.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Source name in the Application Event log pete Windows 64bit 0 03-31-2010 10:01 PM
writing to Application event log John S ASP .Net Web Services 6 09-02-2008 10:03 AM
Logging Application Block Not Writing to Vista Event Log coconet ASP .Net 5 02-12-2008 04:42 AM
My.Log.Writeexception not writing to Application Event Log. =?Utf-8?B?VG9tIFdpbmdlcnQ=?= ASP .Net 0 01-20-2006 06:41 PM
My.Log.WriteException not writing to Event Log with ASP.Net 2.0 Tom Wingert ASP .Net Web Services 0 01-12-2006 06:46 PM



Advertisments