Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Log4Net not logging.

Status
Not open for further replies.

Jacqui1811

Programmer
Jul 8, 2002
100
SG
Hi there.
I have used log4net many times before with success but am having problems getting it to log in this one web site.

I have [assembly: log4net.Config.XmlConfigurator(Watch = true)] in my AssemblyInfo.cs
Here is the code in the page at the top is.
private static readonly ILog log = LogManager.GetLogger(typeof(_edit));

and log.Error("Log Deleted 1"); is further down when I am trying to use it.

Here is my web.config section relevant.
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler"/>
</configSections>

<log4net debug="true">
<appender name="LogFileAppender" type="log4net.Appender.FileAppender,log4net">
<param name="File" value="C:/temp/test-web-log.txt"/>
<param name="AppendToFile" value="true"/>
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>
</layout>
</appender>
<root>
<priority value="ALL"/>
<appender-ref ref="LogFileAppender"/>
</root>
</log4net>

I even have internal debugging on :
<add key="log4net.Internal.Debug" value="true"/>

<system.diagnostics>
<trace autoflush="true">
<listeners>
<add
name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\\temp\\log4net.txt" />
</listeners>
</trace>
</system.diagnostics>

Which seems to work but nothing of any help has been written to the file. Although it has created and written a few lines to it.
I have permissions on the directory set to everyone full control so don't think it can be permissions and we have written the debug file to the same directory.

Would be grateful for any help on this please :)
Thanks.
Jacqui.
 
Hi,
Managed to figure it out I had to call before I tried to do any logging.

log4net.Config.XmlConfigurator.Configure();

All happy and working now :)

Jacqui
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top