Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: IsDebugEnabled = false
Prev Next
You are not authorized to post a reply.

Author Messages
Milind Lad

08/25/2008 7:05 AM  

Hi All,

I am new to log4net. I would to integrate this dll into my application. So I
have done the following steps:
1. I have added log4net dll into my application.
2. Then insert this code
        protected static readonly ILog objLog = LogManager.GetLogger(
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        private showLog()
                {
                        if (objLog.IsDebugEnabled) objLog.Error("While
save");
                }

I hope these are the only steps to integrate log4net into application. But
on load I get IsDebugEnabled FALSE.
So it is difficult to write log.

Please help me!!

Thanks in advance

Regards,
Milind Lad.


Dean Fiala

08/25/2008 1:17 PM  

You need to configure log4net for the application first.  To tell it what to
log and where to log it.

http://logging.apache.org/log4net/release/manual/configuration.html

The XmlConfigurator lets you use an XML file to set up the appenders you
want to use.  It can also be set up to automaticall change your log settings
when the file is updated.  Very handy.

HTH,

Dean

Walden H. Leverich

08/25/2008 3:31 PM  

As Dean pointed out, check that you're actually starting log4net. Also
though, in your example you're checking if the Debug level is enabled,
but you're logging an error. While this isn't "wrong" per-se, it's not
common. I would expect that you'd check Debug if you were logging debug,
and check Error if you were logging error. Then again, you may be doing
something slightly different.

-Walden

--
Walden H Leverich III
Tech Software
(516) 627-3800 x3051
WaldenL@TechSoftInc.com
http://www.TechSoftInc.com

Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)

Daniel Williams

08/25/2008 3:51 PM  

Also, you need to configure the logging system.  A simple way to do it
is to put this into your assemblyinfo.cs file:

[assembly: log4net.Config.XmlConfigurator(ConfigFile="log4net.config",
Watch = true)]

Then make an actual config file called log4net.config and make sure
it's in your app's working folder.  There are many examples out on the
web.  Here is one that will output to the console if you're running
the app from there:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
    <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,
        log4net" />
  </configSections>

  <log4net>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p [%x] - %m%n" />
      </layout>
    </appender>

    <root>
      <level value="ALL" />
      <appender-ref ref="ConsoleAppender" />
    </root>
  </log4net>

</configuration>

Cheers,
Daniel Williams

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > IsDebugEnabled = false



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement