Programmatic/fluent configuration?

May 30, 2011 at 8:01 AM

Is it possible to configure the logging through code?

May 30, 2011 at 10:39 AM

Yes it absolutely is. This is supported since v1.3. You can simply new up LoggingProvider instances and configure them by using constructor arguments. After that you can call them directly or register them in your dependency injection container.

Note that the static CuttingEdge.Logging.Logger facade only reads from the configuration file and will not pick up any manual created LoggingProvider instances. There is no built-in way to attach manually created instances to the facade.

May 30, 2011 at 10:50 AM

I can fix that if you like (just add me as a dev).

Another question: I'm replacing my own logging framework with yours. In mine I got methods in the ILogger interface which is named as the logging level:


// and a exception overload for each method: Will print the exception and all inner exceptions.
logger.Error("Soimething happened", exception");

May I add those to your Logger fascade?

May 30, 2011 at 11:06 AM

I'm not sure it is something that needs to be fixed. What scenario do you have in mind?

I personally don't like having Debug, Error etc methods, besides, it is very easy for a user to add extension methods. Adding those methods directly to the interface would be bad. Look at the ILog interface of log4net and how many methods it has. It is a hell to implement such interface.  In fact the ILogger interface itself is a design error in CuttingEdge.Logging, because the framework itself never uses that interface. It uses LoggingProviderBase instead.

May 30, 2011 at 11:11 AM

I'm creating a VOIP host service where all applications are class libraries. Logging is part of the framework and nothing that my client should configure. Hence the need to be able to use the Logger fascade together with the programmatic configuration.


Extension methods was a great idea.