0

At the moment I am creating a logfunction. I implemented two ILog objects, e.g. logger1 and logger2. I also create two custom appenders (appender1 and appender2) inheriting the AppenderSkeleton class. These appenders create the correct string in the Append method and fires an event.

The problem that I am experiencing is:

The application logs for example:

logger1.Info("test message logger 1");
logger2.Info("test message logger 2");

When I create and activate only logger 2, the Append method of logger2 receives the loglines of logger1 too. How to solve this problem?

I think it is due to the custom appenders aren't connected to a specific log object.

What's the best implemention for this problem?

Odrai
  • 2,163
  • 2
  • 31
  • 62

1 Answers1

0

You have to use the log manager to like:

ILog logger = LogManager.GetLogger("MyLogger1");

And then you can configurer each logger seperately in your configuration file.

Log4Net configuration go to Configuration Syntax to see how to log only one of your loggers.

Peter
  • 27,590
  • 8
  • 64
  • 84
  • The power of the logging frameworks is that you configure them at runtime. So you will beable to change the logging behavour after deployment. You can change the configuration from inside your program by saving a new configuration file. – Peter Jan 29 '13 at 11:08