Hi! PB-LOG is a XML logger to track your application by entering logs of varius kinds (Info, Errors, Events and Warning) with the associated user. Now, it's available for .NET and WP7, but in the future I would want develop this project for Java and PHP. With 1.0 version, the old ways to use PB-LOG is still valid. Now, there are more ways to add, remove, check logs and users.
I wanted write this small XML logger because, as each developer, I needed an easy, but powerful XML logger. I found and tried a lot of loggers, but them were difficult and complicated. PB-LOG is very easy to use and under here there's a code example.
Logger logger = new Logger();
Logger logger = new Logger(@"C:\logger.xml");
Logger logger = new Logger(true)
Logger logger = new Logger(@"C:\logger.xml", true)
For WP7, in the costructor you don't have to write the path, but directly the filename. Like this:
Logger logger = new Logger("logger.xml", true)
User user = new User()
Username = "helloworld",
Rule = "Administrator"
Add log with and without the user:
Log logUser = new Log()
LogType = LogType.Info,
Message = "loading data...",
User = user
Log logNoUser = new Log()
LogType = LogType.Info,
Message = "loading data..."
logger.Logs.Add("message", "username", LogType.Fatal);
="1.0" ="utf-8" ="yes"
<Info Message="Hello, world!" Created="08/04/2012 01:58:37" User="pisolobill" />
<User Username="pisolobill" Rule="Administrator" Created="08/04/2012 01:58:07" />
Users and Logs are custom collection the implement ICollection<T>. I wanted use this interface because their methods (Add, Remove, Contains, ecc.) are already know. ICollection supports queries LINQ and other methods, like this:
if(logger.Users.Exists(u => u.Username == "username" && u.Rule == "rule"))
Log log = logger.Logs;
IEnumerable<Log> getWarnings = logger.Logs.Debugs;
IEnumerable<Log> linq = logger.Logs.Errors.Where(u => u.Rule == "Administrator");
This method will delete the XML file and it will dispose all resources.
How it works
PB-LOG load and write all XML data by XDocument.
04/11/2012 - PB.LOG - 0.9.7
04/24/2012 - PB.LOG - 1.0 - more features, more easy, resolve some bugs
04/29/2012 - PB.LOG - 1.5 - more fast, fixed few bugs (as in every version), more solid foundations (Thank you Alois Kraus for suggestions)
If you have some ideas, suggestions or other, contact me, please.