logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Problem regarding LoggerManager
Date Thu, 10 Jun 2010 14:14:40 GMT
Your wrapper needs to pass its Type into log4net's Log method so the code that processes StackTrace
information knows to skip over certain frames:


public class MyCompanysWrapperLogger : ILog

 private readonly static Type _declaringType = typeof(MyCompanysWrapperLogger);
 private ILogger _log4netLogger;

 internal MyCompanysWrapperLogger(ILog log)
  _log4netLogger = log.Logger;

 public void Info(object message, Exception e)
  _logger.Log(declaringType, log4net.Core.Level.Info, message, e);

----- Original Message ----
From: oritne <oritne@gmail.com>
To: log4net-user@logging.apache.org
Sent: Mon, June 7, 2010 10:10:12 AM
Subject: Problem regarding LoggerManager


I really need help on this issue. I've looked for a solution everywhere but
haven't found one.
Here is my problem:

In the company I work for, A log4net wrapper is being used in order to write
logs into files (and database). The problem is, that when I try to write
details as line number and file name into the log file, I get question
marks, and it happens IN DEBUG MODE, where I have a pdb file.

I've done some testing and found out that it happens only when I use
LoggerManager object. If I use LogManager object it works just fine.

Here is how I use it:

The Log.config:

<logger name="CodeExamples.Program">
      <level value="DEBUG"/>
      <appender-ref ref="Global" />    

<appender name="Global" type="log4net.Appender.RollingFileAppender">      
      <layout type="log4net.Layout.PatternLayout">

This piece of code prints out the question marks:
private ILogger logger;
logger = LoggerManager.GetLogger(Assembly.GetCallingAssembly(),
logger.Log(MethodBaseType, Level.Error, Message, null);

Here is its output:
[07 06 2010 16:11:09,343] ERROR: Attempted to divide by zero.; Logger:
CodeExamples.Program; File: ?; Line: ?; Type: ?;

This one works just fine:
private ILog log;
log = LogManager.GetLogger(Assembly.GetCallingAssembly(),
log.Error(Message, null); 

and the output:
[07 06 2010 16:11:09,365] ERROR: Attempted to divide by zero.; Logger:
CodeExamples.Program; File: D:\Projects\MyLogger\MyLog.cs; Line: 41; Type:

If I could, I would use only LogManager, but the wrapper I work with uses
the LoggerManager, and touching it is the last thing I want to do...

Any help will be appreciated!

View this message in context: http://old.nabble.com/Problem-regarding-LoggerManager-tp28805753p28805753.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

View raw message