»doc flabby Posted January 22, 2008 Report Posted January 22, 2008 (edited) As alot of people find it hard to find to the time to contribute, or would like a nice open and shut task.I'm introducing the weekly coding challenge! You can collaborate or work on your own! Week 1 is nice and easy Week 1--------- Background-------------TCP Needs a way to log stuff. To files and to the console. The current way is to use Console.WriteLine. This is not very good, and provides no way to filter messages. Also its not possible to write to a log file and to screen. A new way of logging events is needed. Whats needed----------------- A way to record different levels of logging (eg. Error, Warning, Info, Debug)Support most types of data (including byte arrays) in human readable form) I suggest making use of String formatting {0}http://blog.stevex.net/index.php/string-fo...ting-in-csharp/ A Logging Interface (which all Logging classes implement)A Class that logs to screen.A Class that logs to a file. A good way to start would be to start with the attached sample code.You can change anything you want. Names and functions are just suggestions. Submission Requirements------------------------------ Zipped and attached to a post to this thread.Must be Licenced GPL2 or compatible OS licence. eg BSD.Must be in C#Do!@#$%^&*ent where you think is necessery (ie clever stuff that isnt obvious)Week1.zip Edited January 22, 2008 by doc flabby Quote
»CypherJF Posted January 22, 2008 Report Posted January 22, 2008 Why reinvent the wheel other then forcing someone to release it under GPL? Use Apache Logging <http://logging.apache.org/>; licensed under the Apache Commons License <http://logging.apache.org/log4net/license.html>. Quote
Samapico Posted January 23, 2008 Report Posted January 23, 2008 heh... good idea. Though I don't think I'll do much this week... I'm trying to get some stuff finished on DCME so I can finally release all those fixed bugs. DCME is currently in a not-compilable state . And I also need to code something for 17th... Quote
»doc flabby Posted January 23, 2008 Author Report Posted January 23, 2008 (edited) Why reinvent the wheel other then forcing someone to release it under GPL? Use Apache Logging <http://logging.apache.org/>; licensed under the Apache Commons License <http://logging.apache.org/log4net/license.html>.Must be Licenced GPL2 or compatible OS licence. eg BSD. Apache Commons License is compatable with GPL. http://www.fsf.org/licensing/licenses/ I never said you had to use all your own code either. Just comply with the entry requirements. Intergrating 3rd Party Tools into a project is a task in itself. Its rarely just a case of plug it in and it works. I'm more than happy if someone takes log4net, makes the necessey changes and submits that. Edited January 23, 2008 by doc flabby Quote
»D1st0rt Posted January 23, 2008 Report Posted January 23, 2008 Here's the logger I wrote for ChatBot that you can use (released here under MIT X11). The architecture is a little different than what you asked for, but it achieves the same functionality aside from array formatting (which could be added quite easily). logger.zip Quote
»CypherJF Posted January 24, 2008 Report Posted January 24, 2008 log4j was pretty easy to use... include the JAR file in the classpath and add the following to your class file private static final Logger logger = Logger.getLogger(ClassName.class); bam, done. Looks from the FAQ all you need is: Here is the suggested usage template: public class Foo { private static readonly ILog log = LogManager.GetLogger(typeof(Foo)); ... other code } An equivalent and more portable solution, though slightly longer, is to use the declaring type of the static constructor. public class Foo { private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); ... other code } Note: the .NET Compact Framework 1.0 does not support System.Reflection.MethodBase.GetCurrentMethod(). Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.