Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Log4Net not creating log file in production?

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.

like image 556
uriDium Avatar asked Aug 22 '09 14:08

uriDium


People also ask

Where is log file log4net?

You can configure the log4net. config file to create log files. The file is located in the webroot\App_data directory of the installation.

What is rolling file Appender in log4net?

RollingFileAppender can roll log files based on size or date or both depending on the setting of the RollingStyle property. When set to Size the log file will be rolled once its size exceeds the MaximumFileSize.

Does log4net support .NET core?

NET Standard (2.0. 7 and beyond). In fact, I can use Log4Net alongside the default logging API for . NET Core: Microsoft.


3 Answers

Fixed. Add the user (which was start the IIS work process) with 'write' rights in 'Properties -> Security -> Edit' for project folder where should be created "Log" file.

like image 66
Viorel Avatar answered Oct 25 '22 15:10

Viorel


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.

like image 38
tvanfosson Avatar answered Oct 25 '22 13:10

tvanfosson


Add this in AssemblyInfo.cs file and check

[assembly: log4net.Config.XmlConfigurator(Watch=true)]
like image 30
Pavan G R Avatar answered Oct 25 '22 13:10

Pavan G R