Thank you for the suggestions .

I tried by  setting the priority level to ALL and changing the loop statements. 
But still , I  have no clue where those error messages are getting logged. More 
info on the background is,

1.I am calling a .Net dll project from  a ASP page ,the parameter includes the 
error string.

2.In my dll project ,I have the log4net implementation .

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

public String logEventErrorASP(String sourceName, String logName, String 
objErr, String strBotListPath)
        {
           log4net.Config.XmlConfigurator.ConfigureAndWatch(new 
FileInfo(AppDomain.CurrentDomain.SetupInformation.ApplicationBase+"log4net.config"));
            //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
           {
               // Exception ex = (Exception)objErr;

               if (log.IsFatalEnabled)
               {
                   log.Fatal("There is an error " + objErr);
                   tempdata = "Warning ";
               }

                   if (log.IsWarnEnabled)
                   {
                       tempdata = tempdata + "Fatal";
                       try
                       {
                           log.Warn(" Unhandled error!" + objErr);
                       }
                       catch (Exception ex)
                       {
                           tempdata = tempdata + ex.ToString();
                       }

                   }

           }

            return 
tempdata+AppDomain.CurrentDomain.SetupInformation.ApplicationBase + 
"log4net.config";

        }

3.I placed the config file in C:\windows\system32\inetsrv\ log4net.config

4. The output in my asp page is Warning Fatal 
c:\windows\system32\inetsrv\log4net.config.which means fatal and warning are 
all returning true.

5.I checked the eventviewer is created but no errors.

5.The event viewer is working fine for aspx pages which is using the  method in 
the same dll .The log4net implementation is in Global.asax for the aspx errors 
and for my asp pages I am passing the error to dll,which has the log4net 
implementation separately for the logging the error [ Anything wrong]

Thanks
Vanitha

From: Roy Chastain [mailto:]
Sent: Wednesday, August 17, 2011 10:24 AM
To: Log4NET User
Subject: RE: How to do configuration in assembly.cs file for log4net 
implementation?

One note for future reference
                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";
Probably does not do what you want.  Either or both Info and Warn could be 
enabled without Debug being enabled.

Try changing Priority to Level in the <root>

If you still do not get log entries, try a more simple appender such as a 
RollingLogFile etc.  The EventLog appender has proven difficult for many people 
and it gets worse under Vista/2008 and above.

----------------------------------------------------------------------
Roy Chastain



From: Venkatasamy, Vanitha [mailto:vanitha.venkatas...@xpandcorp.com]
Sent: Wednesday, August 17, 2011 10:04
To: Log4NET User
Subject: How to do configuration in assembly.cs file for log4net implementation?

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@01CC5CCE.B5285740]


________________________________
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.

________________________________
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