×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Log4Net not logging.

Log4Net not logging.

Log4Net not logging.

(OP)
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.
 

RE: Log4Net not logging.

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close