Log4net cannot write only by creating empty files but not writing actual logs

I can not log any data, errors, debugs using log4net, I tried everything that persission gave for a network service, each in asp.net temp folders, a log folder, even c: \,

it just creates an empty file. but do not write a log

what could be the problem

thanks raj

+7
source share
2 answers

I assume that you did not specify a layout template in your configuration file. Usually you have something like this in your application:

<layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %level %logger - %message%newline" /> </layout> 

Specifies what to write to the journal. If you do not have this, I doubt that he will write anything.

I agree with the comments that said this is probably not a problem because the file is being created. To verify that this is the case, you can add the application to your configuration, which is displayed on the console. Then you can watch the exit while debugging the application. If this does not work, you know that the problem is not a resolution problem.

The best suggestion I can give would be to compare your configuration file with the working one. Make sure that each section has an analog in the working configuration or that you know why this is not necessary. Here is an article I wrote in log4net that includes explanations in each section of the configuration and shows how to write them:

http://www.codeproject.com/KB/dotnet/Log4net_Tutorial.aspx

If all this does not help, send the text of your configuration file to your question so that we can view it.

+9
source

One possible cause of this problem may be the Logging Level . Check if the FATAL logging level is set, and if so, try replacing this part of web.config:

  <log4net> ..... <root> <level value="FATAL" /> <appender-ref ref="RollingFileAppender" /> </root> ..... </log4net> 

with this:

 <log4net> ...... <root> <level value="DEBUG" /> <appender-ref ref="RollingFileAppender" /> </root> .... </log4net> 

Furthemore do not forget to check in the web.config section for possible occurrences of some

  <filter type="log4net.Filter.StringMatchFilter"> <stringToMatch value="test" /> </filter> 

p. In this case, even if the logging level is set to DEBUG (for example), and you enter the code somehow like:

 log.Debug("Db quering..."); 

it will always be empty, but if you write, for example:

 log.Debug("test: Db quering..."); 

Try therefore to comment on sections of the filter, as well as this line.

  <filter type="log4net.Filter.DenyAllFilter" /> 

And this moment, finally, you have to make it work !!

Hope this helps

+2
source

All Articles