My.Log.WriteEntry causes server error

Discussion in 'ASP.NET 2.0' started by Spencer, Aug 7, 2006.

  1. When I attempt to use My.Log.WriteEntry("Some message"), my web application fails at startup. I suspect some security problem.

    I am attempting to use FileLogging, and am not intentionally writing to the event log. The portion controlling logging frommy web.config file is as follows:



    <system.diagnostics>


    <sharedListeners>


    <add location="Custom"


    logFileCreationSchedule="Daily"


    autoFlush="true"


    baseFileName="TestWeb"


    customLocation="E:\web\sqsoftwarec\htdocs\Logs\"


    delimiter="|"


    initializeData="FileLogWriter"


    name="FileLog"


    traceOutputOptions="DateTime"


    type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"


    />


    </sharedListeners>


    <sources>


    <source name="DefaultSource" switchName="DefaultSwitch">


    <listeners>


    <add name="FileLog"/>


    </listeners>


    </source>


    </sources>


    <switches>


    <add name="DefaultSwitch" value="ActivityTracing, Information"/>


    </switches>


    </system.diagnostics>





    The code used in the form (or web service) is also very simple:


    Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load


    Dim strl_Path As String


    Try


    My.Log.WriteEntry("This is a test")


    Catch excl_Error As Exception


    Label1.Text = excl_Error.Message


    Label3.Text = excl_Error.StackTrace


    End Try


    End Sub


    The message that I am getting is:


    Access to path '\Microsoft Corporation\Internet Information Services\6.0.3790.1830' is denied.
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    from the error, it looks like your application is trying to write to a location that it doesn't have right to.


    I suggest you make sure the path is correct. If you still have problem, please submit a ticket in the control panel.


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Bruce,


    Thanks for your response. I have verified that I can perform a write to the operation using the same path as the MS provided logging component supplies.


    I'll post a ticket.


    Spencer
     
  4. Unfortunately, you will not be able use Microsoft.VisualBasic.Logging.FileLogTraceListener. Even if you configure a custom location, it will still first attempt to check if the default location exists. If the default location doesn't exist then it will try to create it, and this is where the problem occurs.

    The default location is within the user's Documents and Settings folder. Since DiscountASP does not setup Windows profiles for the ASPNET users, the default location cannot be found nor created. Then it will try find and create other locations like 'C:\Documents and Settings\Default User\Application Data\Microsoft Corporation\Internet Information Services\6.0.3790.1830', which also does not exist nor do customers have permissions to.

    Try using the System.Diagnostics.TextWriterTraceListener class instead.

    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET

    Post Edited (Aristotle [DASP]) : 8/9/2006 7:54:12 PM GMT
     

Share This Page