Last week I released a new version of Common Logging 2.0 for the .NET platform. You can get the distribution as well as online API and User Reference documentation from the project website. For users of previous versions there is also a section about upgrading to 2.0.
What is Common.Logging?
Similar to Java's Apache commons-logging, Common.Logging is an ultra-thin brigde between different .NET logging implementations based on original work done by the iBatis.NET team. A framework or library using Common.Logging can be used with any logging implementation at runtime and thus doesn't lock a user to a specific framework or worse letting him struggle with different frameworks using different logging implementations.
Common.Logging comes with adapters for all popular logging implementations like log4net and Enterprise Library Logging.
Bridging between logging implementations
You might run into the problem, that libraries used by your application use different logging implementations. Common.Logging allows you to route from those implementations into any logging system of your choice:
Please see reference documentation for an example on how to configure such a bridging scenario.
What's new in 2.0?
Several extensions and improvements were made, namly
- Dropped .NET 1.1 Support
- Added support for Enterprise Library 4.1 Logging
- Extended and improved ILog Interface
- Convenience LogManager.GetCurrentClassLogger() Method
- Bi-directional log event routing between logging implementations (see bridging above)
- Improved performance
I already blogged about comparing Common.Logging performance to System.Diagnostics.Trace. According to a thread on stackoverflow, log4net seems even slower than System.Diagnostics.Trace.
Configuring Common.Logging
For examples on how to configure and use Common.Logging and bridge different logging implementations, please see the user refererence guide. The API documentation contains configuration and usage examples on each adapter implementation. Here is an example for configuring Common.Logging to write messages to the console:
<configuration> <configSections> <sectionGroup name="common"> <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" requirePermission="false" /> </sectionGroup> </configSections> <common> <logging> <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging"> <arg key="level" value="ALL" /> </factoryAdapter> </logging> </common> </configuration>
Using Common.Logging
Using Common.Logging is as simple as shown below:
ILog log = LogManager.GetCurrentClassLogger(); log.DebugFormat("Hi {0}", "dude");
Hint: When using NET 3.5, you can leverage lambda syntax for logging to avoid any performance penalties:
log.Debug( m=>m("value= {0}", obj.ExpensiveToCalculateInformation()) );
This is the equivalent to writing
if (log.IsDebugEnabled) { log.Debug("value={0}", obj.ExpensiveToCalculateInformation()); }
and ensures that you don't have to pay for calculating the debug information message in case level "Debug" is disabled.
Further Roadmap
The following features and improvements are planned for the next release, some of them already in the works:
- Partial Trust compliance (already in the trunk)
- Support for Windows Azure
- Support for Silverlight
- Logging (aka 'Trace') Context support (in progress) see System.Diagnostics.CorrelationManager and log4net contexts for examples
Of course I would like to invite you to submit any feature request, bug reports or other improvement suggestions to the project's issue tracker.
Happy logging!
34 comments:
Thanks for this release! I hope opensource projects like NHibernate and others will switch to the Commonlogging approach at some time.
Even better! I just read "Bridging between logging systems" (http://netcommon.sourceforge.net/docs/2.0.0/api/html/index.html), this is exactly what I was looking for!
Hi,
glad u like it!
in case you would like to see Common.Logging in your favorite framework, spread the news and let the makers of those frameworks know!
I'm seeing some problems opening the project in Visual Studio 2008 SP1, it seems that the paths for the testing frameworks are too long. It opens correctly when I move the project to the root of my drive, but I do not want to keep my projects there. I prefer to keep my projects in the standard My Documents\Visual Studio 2008\Projects folder. Is there any way to release an update that will fix this problem?
@Erik: sure there is - it is just a matter of time that I am currently seriously lacking. Helping hands are absolutely welcome!
hi Eric,
thank for your blog. Hope you still maintain this blog. I am trying to download Common.Logging v2.0.0 in the sourceforge website that you suggest. But it appears when i tried to uncompress the zip file it was corrupted. I tried to download and uncompress older version and it works. Do you have any idea other website that i can download ? currently i need that component for my .NET development. Thanks in advance for your help
@Zuleika, I successfully downloaded it via:
http://downloads.sourceforge.net/project/netcommon/Common.Logging/Common.Logging%202.0.0/Common.Logging-2.0.0.zip?use_mirror=ovh
This should also work for you.
@blog : Thank you for your reply, i tried to download from the link that you have provided and same error happened when i want to uncompress it using Windows-built zip extractor("The Compressed (zipped) Folder is invalid or corrupted"). But then i tried to use another software called 7-zip for uncompress the .zip files and gladly it works :). Anyway thanks for your help
it seems I used a WinZip version for zipping things up, that produces an incompatible .zip format by default. I will upload a re-zipped version this weekend. Sorry for the inconvenience!
Greetings! Very useful advice in this particular post! It is the little changes that will make the greatest changes. Thanks a lot for sharing! oneplus 7 pro display replacement bangalore Howdy! This blog post could not be written much better! Going through this article reminds me of my previous roommate! He continually kept preaching about this. I most certainly will send this information to him. Fairly certain he's going to have a very good read. Thanks for sharing! vivo V17 pro display replacement marathahalli
Hello, I do think your web site could possibly be having web browser compatibility problems. Whenever I take a look at your blog in Safari, it looks fine however when opening in Internet Explorer, it's got some overlapping issues. I simply wanted to provide you with a quick heads up! Other than that, wonderful site! samsung M30s display replacement Having read this I thought it was very informative. I appreciate you spending some time and effort to put this informative article together. I once again find myself spending a lot of time both reading and posting comments. But so what, it was still worthwhile! iphone 11 pro display replacement marathahalli
Hi there! I could have sworn I’ve visited this blog before but after browsing through a few of the articles I realized it’s new to me. Anyways, I’m certainly happy I came across it and I’ll be bookmarking it and checking back regularly! redmi note 8 pro display replacement bangalore I needed to thank you for this great read!! I certainly loved every little bit of it. I've got you bookmarked to check out new things you post… realme 5s display replacement
The style of writing is excellent and also the content is top-notch. Thanks for that shrewdness you provide the readers! to read. I never stop myself to say something about it. You’re doing a great job. Keep it up...
Very useful blog thanks for sharing IndPac India the German technology Packaging and sealing machines in India is the leading manufacturer and exporter of I hope I will see again. You can use this for any quantum realm white jacket kind of academic writing work.
Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery
This blog was really good formatting, thanks for sharing with us. Visit Ogen Infosystem for professional website designing and digital marketing services at good price.
Website Designing Company in Delhi
Are you looking for the best Web Development Company in Abu Dhabi? If yes then connect with CSS Founder to get the user and seo friendly website for your business.
Looking for the best tent suppliers in Dubai, United Arab Emirates? If yes then connect with Al Mumtaz Tents service provider. You can make more impressive your party and events by connecting with us.
Tent Companies in UAE
We can provide the best ranking to your website on Google so that you can get more business. Just connect with the best SEO Company in Noida. Yes, PromoteDial can be the right choice for you.
Are you looking for a company that can provide you Work permit in malta? If yes then connect with Steadfast Services, it will good for you.
If you are interested in getting the best flats & apartment at the best location and at an affordable price then you should go with Exotica Housing. We can be the right choice for you.
Luxury residential projects in sector 79 Noida
If you are interested in judging our company If you are looking for a good and honest web design company, and you want to get a good website design done, then let us tell you about our website design company which is in this business. is the best, contact us,
Website design company base lona
Is your goal to grow your digital presence? If you are creating a website especially to promote your product or brand, if you want to design a website related to your business then contact us.
Web design company Vancouver
https://www.cssfounder.com/
CSS Founder is a top-rated website design and SEO company that provides cost-effective and result-oriented website design and SEO services to clients.
Website design company Amsterdam
prevail! it may be one of the most useful blogs we've ever come across upon the situation. terrific data! Im plus an skillful in this subject matter correspondingly i can take your effort completely dexterously. thanks for the large backing. https://wishesquotz.com/brothers-day-quotes/
autoclave cooker type
Pormotedial is the best SEO company in Dammam, we are the leading company in the SEO field, We have a skilled team that provides you with better result and optimize your website.
Almumtaz is the best Tents Rentals company in UAE, we can make a perfect tent according to your need. We are professionals in this field, for more information please visit our website
Nice message, I read this blog all the time and it made me very happy.
https://getcrackpc.com/passfab-wifi-crack/
Thousands Have Lived Without Love, Not One Without Water UV Ultraviolet 12-24-36 GPM Vertical Type
Thanks so much for providing such a nice information. Resorts in Lansdowne with Swimming Pool
Learn secret of happy life with us. Hotels in Lansdowne
Thanks for your nice blog. Contact us for Baby Sitter
Thanks for your best article. Sarita Nursing Bureau provides best Nursing Care at Home in Noida
CSS Founder has a team of experienced web designers and developers, we strive to provide our clients with high-quality websites that not only look great but also deliver results. Whether you need a simple brochure website or a complex e-commerce platform, our expertise and creativity will ensure that your website stands out from the competition, which is why it is known as the best website designing company in Faridabad. Contact CSS Founder in Delhi today for all your website designing needs and let us help you build a strong online presence.
Post a Comment