You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Ron Grabowski <ro...@yahoo.com> on 2005/07/01 05:25:11 UTC
Re: Configuration Questions
If GetClassName() were implemented to return a string:
static string GetClassName();
The code would look something like this:
ILog log = LogManager.GetLogger("Company.Project.User);
ILog auditLog = LogManager.GetLogger("AUDIT.Company.Project.User");
Putting the AUDIT in front is a simple way to direct AUDIT logs to a
seperate appender while preserving the namespace structure in case you
want to do additional processing later.
http://tinyurl.com/7nccu
http://logging.apache.org/log4net/release/manual/introduction.html#hierarchy
I can't think of a good way to explain it other than try running your
application configured with a few loggers and experiment when their
additivity settings set to true then false.
--- Weston Weems <ww...@gmail.com> wrote:
> one quick question on this subject btw...
>
> how does GetLogger know to get the AUDIT log if I am throwing a class
> type in there as well?
>
> Is that what additivity is?
>
>
>
>
>
> On 6/29/05, Weston Weems <ww...@gmail.com> wrote:
> > Exactly the kind of thing I was looking for.
> >
> > On 6/29/05, Ron Grabowski <ro...@yahoo.com> wrote:
> > > You could prefix a second logger with AUDIT to differentiate
> messages
> > > coming from the same class:
> > >
> > > ILog log = LogManager.GetLogger(GetClassName());
> > > ILog auditLog = LogManager.GetLogger("AUDIT." + GetClassName());
> > >
> > > auditLog.Info("The user has logged in.");
> > >
> > > <logger name="AUDIT" additivity="false">
> > > <level value="INFO" />
> > > <appender-ref ref="AuditAdoNetAppender" />
> > > </logger>
> > >
> > > --- Weston Weems <ww...@gmail.com> wrote:
> > >
> > > > Ok, after re-evaluating my needs... heres what I've decided...
> > > >
> > > > 1) I need basic logging functionality with normal levels (this
> much I
> > > > can figure out fairly easily)
> > > >
> > > > 2) I will be using log4net to record audit logging, eg login
> > > > failures... and stuff I'll be reporting against so it'll have
> to be
> > > > databased (sql server)
> > > >
> > > >
> > > > I've written configs that will allow me to write extra data to
> the
> > > > logs (fatal gets sent to email appender) etc... and it seems to
> work
> > > > decently, but my question is more for point number 2. What
> would be
> > > > the best way of filtering "more static" logging mechanisms...
> > > >
> > > > Eg, I want auditing log stuff written to a seperate table. I
> was told
> > > > I can create custom levels, but I'd prefer to stick to using
> levels
> > > > for levels.
> > > >
> > > > Should I have more than one ILog at any given point in a given
> > > > context?
> > > >
> > > > I know I can achieve my goals, its just by which method etc.
> > > >
> > >
> > >
> >
>