Wednesday, August 15, 2007

Spring.net Common Logging for Testing

del.icio.us Tags: , , ,

Commonly, we use log4net for unit testing in .net, because of it's standard log4j-like style. But sometimes it seems that log4net not stress-effective, so remove dependency on it is right decision. In .net there isn't any widely adopted library for this like Jakarta's Commons Logging, so as we use Spring.net for DI, we use it's Common Logging library, which let us decoupling from log4net.

One thing that we not understand immediately is that how to configure logmanager in unit tests.

In log4net (as well as log4j) you can simply use BasicConfigurator:

1 BasicConfigurator.Configure(); 2 3 LogManager. 4 GetLogger(typeof(C1DocC1DirectDAOTest)). 5 Debug("LOGGING SETUP");

But using it with Common Logging has no effect. Right way is setting adapter for LogManager.

1 NameValueCollection properties = new NameValueCollection(); 2 properties["level"] = "Debug"; 3 4 Common.Logging.LogManager.Adapter = 5 new ConsoleOutLoggerFactoryAdapter(properties); 6 7 Common.Logging.LogManager.GetLogger(typeof (C1DocC1DirectDAOTest)). 8 Debug("SPRING LOGGING SETUP");

Other implementations can be found in doc.

Tuesday, August 14, 2007

Known facts and delusions about football

Wikipedia's page on football has very interesting map about popularity of football around the world.

Description for it is simple - in green countries football are sport number 1 and red - not. In this nothing interesting, in australia it's rugby, usabasketball, india/pakistan - cricket, canada and finland - ice hockey, in china competitor of football is Ping Pong i think.

 

More interesting is saturation. Ok, we all know that USA is most sports nation, but did you ever think that per 1000 people in USA more players than in Brasil or Argentina?