I’ve blogged about using MongoDb to store log4net logs,
but the original appender has a littleproblem, it stores a BsonDocument inside the MongoCollection, and does not use any C# object andwhen it is time to query data you cannot use the new LINQ Mongo provider that is included in newest C# drivers (1.4), because data is completely untyped.
This is usually not a big problem, because you can querya collection using simple JSON-like query, but if you are used to standard LINQ provider, probably you will get alittle bit lost on how to create the JSON query to retrieve the data you need.
This is the scenario I need to solve:
I have a stupid Winform. that is able to show someinformation from a standard Log4Net Sql database (using the adonetappender) andI want to be able to use the very same interface to load data from mongodatabase.
First of all I need to load all distinct value for the property level and loggerName, because I have acombo where the user can filter for Severity (ERROR, WARN, INFO, Etc.) and alist of checkboxes used to filter for loggerName. Luckily enough, mongo offersuch a functionality out of the box.
CODE:var db = server.GetDatabase(bsDatabase.Current as string);
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/301743/viewspace-731253/，如需转载，请注明出处，否则将追究法律责任。