If you name your loggers after your class's full name, this works out naturally.
http://logging.apache.org/log4net/release/manual/introduction.html#hierarchy Getting a logger with the name "Namespace1.Namespace2.ClassName" will add "Namespace1", "Namespace1.Namespace2", and "Namespace1.Namespace2.Classname" to the hierarchy. Then, you can configure them accordingly: <logger name="Namespace1"> <appender-ref ref="Appender1" /> </logger> <logger name="Namespace1.Namespace2"> <appender-ref ref="Appender2" /> </logger> <logger name="Namespace1.Namespace2.ClassName"> <appender-ref ref="Appender3" /> </logger> So class Namespace1.Namespace2.ClassName will go to Appender3, all other classes in Namespace1 not in Namespace2 as well will go to Appender1 only. Since loggers inherit from their ancestor, classes in Namespace1.Namespace2 not named "ClassName" will only go to Appender1 and 2, but not 3, etc... On 4/19/06, Julien Sobrier <[EMAIL PROTECTED]> wrote: > Hello, > How can I restrict the logging to a namespace or a class? > > My project uses several namespaces and classes, and I'd like to have > several log files: > * one for all classes (done) > * other log files for just one class or just one namespace. > > Thank you > Julien >
