views:

1284

answers:

8

I am using VS2005, a website project, a web deployment project and Log4Net. I can use logging when I am developing locally. I can see the log files and everything is fine. When I build my website, (using the web deployment project), I use the deploy as a single DLL option. When I then check the locations of where my log files should be I cannot see any files.

Is there a way to troubleshoot this. I don't think adding the debug value to the App Settings will help because I don't have a console because it is a website.

EDIT I don't want the 150 rep to go to waste so one last time. I compared the internal trace from my dev environment to the trace from the production. My dev environment trace shows the call the Xml Configurator where the production one does not. I have code in the global.asax on application_start() method. I put debug code in there and it is getting called in dev but not in production.

I think this is where the web deployment project is causing some issues. Does the global.asax get compiled into the single DLL? When I do a build in the deployment directory I see a global.compiled file. Must this go into the bin folder in production? Or is the global.asax code in the single DLL? Having both in the bin folder or the just the DLL didn't change anything.

+1  A: 

This has happened to me before and was permissions on the ASPNET user to create the files where needed. Can check if there is anything in the windows event log indicating this?

To check for the kind of thing (we watch the watcher!) we output where the log4net was going to work by writing this out using the OutputDebugString() via pinvoke.. We also put this in a try catch to ensure that we discover errors regarding this as it's very important to use to be able to log correctly.

Preet Sangha
+1  A: 

Does the worker process have sufficient privileges to write to the log directory? I'm guessing that's not the case. You might want to give the worker process group rights to write to the directory and see if that fixes your problem.

tvanfosson
Which groups must I give write permissions to. I thought it was the Network Service?
uriDium
I think there is a local group, IIS_WPG, that I would use. Typically, any accounts running worker processes should be put in this group. Using the group protects you in case you decide to change the account for some other reason. Also, if your log directory is in the web site, make sure you set up some protection on it so people can't do requests against it.
tvanfosson
Thank you for the advice. Is there any where we I can read up on this. I am really new to security and permissions.
uriDium
You might want to try the documentation for IIS. http://technet.microsoft.com/en-us/library/cc775635(WS.10).aspx (IIS6) or http://www.iis.net/ (IIS7).
tvanfosson
A: 

Check the permissions on the expected output directory and ensure that the web-service can write to it. The simplest way to do it is to run filemon.exe (a SysInternals app) and restrict it accordingly. This should tell you if anything fails and you can fix as necessary

Gordon Carpenter-Thompson
I have run filemon and filtered for *log. The only file that appeared was Log4Net's internal debug file. It did not attempt to open write anything to the desired log files.
uriDium
A: 

Make sure log4net get's configured properly. Maybe the dll is alright but the config file is missing? log4net could be there but just does not have any active appenders.

galaktor
A: 

hi to make sure if log4net is configured properly i do create a UDP Appender that logs to port 9090. i use chainsaw http://logging.apache.org/chainsaw/index.html to check the log entries.

with this you you can check that at least some logs entries are done and that the logger is running.

UDP Appender Config

<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
     <remoteAddress value="localhost" />
     <remotePort value="9090" />
     <layout type="log4net.Layout.XmlLayoutSchemaLog4j">
      <locationInfo value="true" />
     </layout>
</appender>

Chainsaw XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> 
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">    
    <plugin name="LocalReceiver" class="org.apache.log4j.net.UDPReceiver">
        <param name="Port" value="9090" />
    </plugin>    
</log4j:configuration>
nWorx
I have tried this. A couple of things that confuse me. I do not have a log4j configuration file. I am using Log4net. Will this still work? Next thing, I used my web config file to keep my settings (works in dev). I opened port 9090 but Chainsaw seems to listen on port 4445 and 4560. Should I just put the above in a file somewhere and try again?
uriDium
Also, one last thing, I see that you point the plug-in to an apache class. Must I download those classes too or are they included in the webstart?
uriDium
just save the second xml as a file and as soon as you start chainsaw, you can open a configuration file -> if you are not asked to choose a configuration file than you have to delete the ".chainsaw" directory in your user directory.you do not need a log4j configuration, just use your web.config -> but add this appender as configured as above
nWorx
+1  A: 

It looks like the root of your problem is that the Application_Start event in global.asax is not firing.

There is a "known" problem when deploying from VS 2005 to Windows 2003, that the Application_Start does not fire.

The contents of Global.asax.cs will be compiled into the dll. But the Application_Start will not run unless the file Global.asax is present.

Here are a couple of relevant links:

http://accidentaltechnologist.com/asp-net/application%5Fstart-not-firing-and-the-globalasax/

http://www.velocityreviews.com/forums/t300292-web-deployment-projects-globalasax-problem.html

There are some other possibilities that are covered in the above links.

Hope this helps

Shiraz

Shiraz Bhaiji
+1  A: 

I have found the problem. Permissions were CORRECT. Turns out that using a web deployment project also creates a precompliled.config file in the root. I had not copied that to the production enivornment. As soon as that was in the everything worked. Sorry no one got the bounty.

uriDium
A: 

Add this in AssemblyInfo.cs file and check

[assembly: log4net.Config.XmlConfigurator(Watch=true)]
Pavan G R