> -----Original Message----- > From: Russell Haley [mailto:[EMAIL PROTECTED] > Sent: 14 June 2005 18:00 > To: log4net-user@logging.apache.org > Subject: Info Only Appender > > I want to start by thanking Nicko Cadell for his previous > response to this problem. I'm very pleased that there is a > place to find answers for Log4Net. > I was able to configure my appenders to work in tandem, but I > still have an issue. > > 1) I have created 2 custom appenders that are to log > different message levels that are returned from my > application. One appender is to record all logging levels, > while the other is to log ONLY the "Info" entries. Nicko > Cadell suggested I use the Threshold property and assign a > value of "Info". > My observation, however, is that the appender with the > threshold of "Info" > logs everything but "Debug" statements. As usual, I'm sure > I've simply missed something.
Levels fall into a sliding scale. The threshold allows events through that are equal to or above the threshold value. If you want only INFO events then you need to use a LevelMatchFilter: <appender name="SystemEventInfoLog" type="log4net.Appender.RollingFileAppender"> <filter type="log4net.Filter.LevelMatchFilter"> <LevelToMatch value="INFO" /> </filter> <filter type="log4net.Filter.DenyAllFilter" /> ... </appender> > > 2) I would like to create another totally different logger > and any design input would be most appreciated. > > The "new" logger/appender will log real-time messages to > whatever appender the user chooses and will have a very > specific format (real-time being a min. of 1 second and no > max). The data to be logged is mainly date time, message type > (a constant value I will assign to each message that comes > in) and the message content. I do not need to assign a log > level to these entries and would prefer to not have to deal > with log level in my files. The application can have a number > of "Systems" that return real-time messages and I would like > to be able to log the messages for each system in a separate > file (or table) that will use the "System ID " to demark the > folder and filename that is created. Unfortunately my > experience with formatters/layout/objectRenderer is very > thin. Does anyone have any feedback for this? I assume that I > will have to dynamically configure the logger/appender in my > code. Will I need to alter the log4net source to achieve this > sort of functionality? Log4net supports dynamic programmatic configuration. You can create and configure appenders and attach them to a hierarchy of loggers. You may want a 1-to-1 mapping from loggers to appenders. If you want to output to a medium supported by an existing appender then you should try to reuse it, however if you want to output to something new it should be simple to write your own appender in your own assembly. You should be able to do the rendering of your message using a Layout, probably the PatternLayout will do what you need, but again you can write your own if required. > On a side note, is there a list of ConversionPattern > Constants? (i.e. %d [%t] %-5p ...) http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayo ut.html > How about appender parameters? Something like this? http://logging.apache.org/log4net/release/sdk/log4net.Appender.FileAppen derMembers.html The SDK docs are here: http://logging.apache.org/log4net/release/sdk/index.html Cheers, Nicko > > Thanks once again to the Log4Net team. I hope that with a > little more experience I will be able to start contributing > in some way to this great piece of software, instead of just > crying for help. :) > > Sincerely, > > Russell Haley > Software Developer, > Axys Technologies > http://www.axystechnologies.com > > > >