HI,
I am trying to implement the log4net. In my project ,i am referring a dll 
project,which has the log4net implementation and i am calling the dll from from 
my asp number.

  The call is successful from asp to dll method and the logger is created just 
fine.


    private static readonly ILog log = 
LogManager.GetLogger(typeof(ErrorLogging).Name);

But the problem is the logger is not enabled. I mean 
IsErrorEnabled/IsDebugEnabled are false.

The confusing part to me is assembly.cs,in which the place where we mention the

    [assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = "log4net", 
Watch = true)]
    // This will cause log4net to look for a configuration file
    // called TestApp.exe.log4net in the application base
    // directory (i.e. the directory containing TestApp.exe)
    // The config file will be watched for changes.

So ,do i need to create a file with .log4net extension ,if so i tried and its 
not working.
And not working from my web.config also.

Please see my web.config code



    <log4net debug="true">
    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <param name="LogName" value="PortalWebLog" />
      <param name="ApplicationName" value="Portal" />
      <eventId value="6" />
      <eventCategory value="10" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger 
[%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <root>
      <priority value="DEBUG" />

      <appender-ref ref="EventLogAppender" />
    </root>
  </log4net>

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

And the dll method ,where i am accesing the log

    log4net.Config.XmlConfigurator.Configure();
            log4net.ThreadContext.Properties["EventID"] = 6;

            String tempdata=string.Empty;

            if (!System.Diagnostics.EventLog.SourceExists(sourceName))
            {
                tempdata = sourceName + logName + objErr + strBotListPath;
                System.Diagnostics.EventLog.CreateEventSource(sourceName, 
logName);
            }
            else
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("This is a DEBUG level message. The most VERBOSE 
level.");
                    log.Info("Extended information, with higher importance than 
the Debug call");
                    log.Warn("An unexpected but recoverable situation 
occurred");
                    tempdata = "Source already exits";
                }
                else
                {
                    tempdata = "Source already exits,but debug not enabled";
                }
            }

After removing the below line

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

and by placing the log4net.config in C:\windows\system32\inetsrv,the error log 
is enabled and changing the line,
     log4net.Config.XmlConfigurator.ConfigureAndWatch(new 
FileInfo(AppDomain.CurrentDomain.SetupInformation.ApplicationBase+"log4net.config"));

The IsDebugEnabled is true but  i am not seeing any errors in the eventLog and 
its empty


DEV Environment :Windows 2003 ,log4net for .Net framework2.0 [1.2.10.0]

Thanks,
Vanitha Venkatasamy
XPAND Corporation.
[cid:image001.jpg@01CC5CC5.0C41E6E0]


________________________________
This message contains Devin Group confidential information and is intended only 
for the individual named. If you are not the named addressee you should not 
disseminate, distribute or copy this e-mail.
Please notify the sender immediately by e-mail if you have received this e-mail 
in error and delete this e-mail from your system. E-mail transmissions cannot 
be guaranteed secure, error-free and information could be intercepted, 
corrupted, lost, destroyed, arrive late, incomplete, or contain viruses. The 
sender therefore does not accept liability for errors or omissions in the 
contents of this message which may arise as result of transmission. If 
verification is required please request hard-copy version.

<<inline: image001.jpg>>

Reply via email to