I'm trying to Log some info-type messages from my app and keep getting a Server error.

Discussion in 'Hosting Services / Control Panel' started by johnpavelka, Dec 5, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I'm trying to Log some info-type messages from my app and keep getting a Server error. What is the pathname I would use in my app if the Log.txt file resides in my root?

    Thanks in advance.

    jP


    Post Edited By Moderator (Joel Thoms) : 12/6/2006 12:38:20 AM GMT
     
  2. Takeshi Eto

    Takeshi Eto DiscountASP.NET Staff

    The server path is listed in your Control Panel in the Acount Information section.

    Eric
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  3. this is the last code I tried. It doesn'tgenerate an error, but it isn't writing to my Log file. I know it is writing 'somewhere' because I change the pathname when developing on my machine and it works fine.

    I'm not sure why the 'lnk' extension gets added when I upload a .txt file to my root??? Is that part of the problem??

    Thanksfor your patience.

    jP




    mypath = "e:\web\jpavelkaorg\Log.txt.lnk"


    Dim filex As New IO.StreamWriter(mypath, True)


    filex.WriteLine(OutStr)


    filex.Close()
     
  4. UseServer.MapPath("Log.txt") for path

    i.e

    mypath = Server.MapPath("Log.txt")




    Dim filex As StreamWriter


    filex = New StreamWriter(mypath , True)


    filex.WriteLine(OutStr)


    filex.Close()







    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. this is embarrassing. I can't get anything to work. It looks like VS 2005 doesn't support server.mappath. I tried HostingEnvironment.mappath("Log.txt") and it tells me a virtual path isn't valid here. I'll keep trying things. [​IMG] If you have a light-bulb come on. Feel free to teach me some VB.NET.

    Thanks,

    jP
     
  6. You mean your VS 2005intellisense is not show up Server.Mappath?Are you getting any kind of error?

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. vs 2005 does support server.mappath. If you could paste us some code to see how you are using it. Please paste the whole page wtih server.mappath in it.

    Also, could you be using c#? If so, then Server.MapPath is case sensitive.





    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  8. Thanks. I'm kind of new at this. It was a in a class, so I'm told that I need to usethe HttpConText.current.server. Thanks for your help.


    jP
     
  9. The only 'server path' I see in the Account Info is "e:\web\jpavelkaorg\htdocs"

    my file 'log.txt' is in my root. does this mean the path to the log is

    e:\web\jpavelkaorg\htdocs\log.txt ?? I can't get this to work. what am I missing.

    thanks in advance.

    jP
     
  10. Bruce

    Bruce DiscountASP.NET Staff

    You should always use server.mappath function if possible. However, the path you hardcoded should work just fine.


    What error are you getting?


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  11. please provide both the error message and a url to an example of the problem you are experiencing.



    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page