Query a Log4Net-database
- by pinhack
So if you use Log4Net to log into a database (i.e. using the AdoNetAppender), how can you conveniently get an overview of what has happend ? Well, you could try the following Query ( T-SQL ):
SELECT convert(varchar(10),LogDB.Date,121) as Datum, LogDB.Level, LogDB.Logger,COUNT(LogDB.Logger) as Counter
From Log4Net.dbo.Log as LogDB
where Level <> 'DEBUG'
AND convert(varchar(10),LogDB.Date,121) like '2010-03-25'
GROUP BY convert(varchar(10),LogDB.Date,121),LogDB.Level,LogDB.Logger
ORDER BY counter desc
This query will give you the number of events by the Logger at a specified date - and it's easy to customize, just adjust the Date and the Level to your needs.
You need a bit more information than that?
How about this query:
Select
convert(varchar(10),LogDB.Date,121) as Datum,LogDB.Level,LogDB.Message,LogDB.Logger ,count(LogDB.Message) as counter
From Log4Net.dbo.Log as LogDB
where Level <> 'DEBUG'
AND convert(varchar(10),LogDB.Date,121) like '2010-03-25'
GROUP BY convert(varchar(10),LogDB.Date,121),LogDB.Level,LogDB.Message,LogDB.Logger
ORDER BY counter desc
Similar to the first one, but inclusive the Message - which will return a much larger resultset.