hendryluk / cormo

.NET Application Framework based on Spring and Java EE CDI
MIT License
5 stars 4 forks source link

Logging #9

Open hendryluk opened 9 years ago

hendryluk commented 9 years ago

From Jboss Weld. A simple support for logging:

public class MyClass
{
   [Inject, Logger] ILogger _logger;
}

Which is equivalent to the traditional way:

public class MyClass
{
    private static ILogger _logger = LogFactory.GetLogger(typeof(MyClass));
}

This should be part of the Cormo core (instead of a separate module). However I'm thinking of using CommonLogger (instead of a specific logging framework, due to fragmentation of .net loggers), with the downside being it requires developers to add an extra nuget (for their logging-framework of choice) to get logging happen, instead of just happen by default without the need to add any other dependency. But at least by default it should write logs to .net's Debug and Trace. This also includes writing log entries from within all over Cormo codebase.

Jboss Weld also comes with more advanced ways of logging, such as typed logging, message-bundles, and internationalization. I'm not sure how much value it will add to us, so I'm deferring that implementation and just stick with a simpler logger injection for now Ref: https://docs.jboss.org/weld/extensions/reference/latest/en-US/html_single/#logging