So I should created one logger (fe. named "users") and add to them only
one - my own appender that will be distribute events to specified
file appenders? (it will be check to which context of user it should write,
it find this user file appender and call for them append function?)
In each case, when i call function debug, info etc, I select right file
appender (in this way to call append function?) (If I exactly good
understand?)
I don't know exactly how to protect main logger won't to write to many user
files (file appenders) simultaneously.
regards
chris

----- Original Message -----
From: "Mark Womack" <[EMAIL PROTECTED]>
To: "'Log4J Users List'" <[EMAIL PROTECTED]>
Sent: Tuesday, January 14, 2003 6:29 PM
Subject: RE: When any logged user has his own logger file


> I'm sure there are more than a few ways to do this, but one way that comes
> to mind...
>
> - Modify your code to set up the user information in the MDC before
> processing each request (I'm assuming a web application here, so see the
> current cvs for org.apache.log4j.servlet.CookieMDCFilter for an example of
a
> servlet 2.3 filter that does this).
>
> - Write your own custom appender that looks at the user value in the MDC,
> uses it to do a local lookup for a file appender for that user (simple
hash
> map lookup).  If it finds it, append the event to that appender.  If it
does
> not find it, then create the appender, store it for future reference under
> the user key, and then append to it.  Add a custom method to
remove/shutdown
> the user related appenders when the user id invalidates.
>
> hth,
> -Mark
>
> > -----Original Message-----
> > From: Krzysztof Krzos [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, January 14, 2003 9:22 AM
> > To: Log4J Users List
> > Subject: Re: When any logged user has his own logger file
> >
> >
> >
> > //I create my category:
> >     MyCategoryKK logger =
> > (MyCategoryKK)MyCategoryKK.getInstance("users.UsrLogger-"+requ
> > est.getRemoteU
> > ser()+"-"+sess.getCreationTime());
> > //Create appender
> >      FileAppender app=new FileAppender();
> >
> > app.setName("UsrApp_"+request.getRemoteUser()+"_"+sess.getCrea
> > tionTime());
> >
> > app.setFile(path+"/breadmin_"+request.getRemoteUser()+"_"+strD
> > ate+".log",tru
> > e);
> >      PatternLayout lay = new PatternLayout();
> >      lay.setConversionPattern("%d %-5p [%t] %C{2} (%F:%L) - %m%n");
> >      app.setLayout(lay);
> > //and add this file appender to category
> >      logger.addAppender(app);
> >
> > //when session invalidate I call
> >     logger.removeAllAppenders();
> > //so I remove all appenders but category stay (like you said,
> > it can't be
> > destroyed)
> > chris
> >
> > ----- Original Message -----
> > From: "Mark Womack" <[EMAIL PROTECTED]>
> > To: "'Log4J Users List'" <[EMAIL PROTECTED]>
> > Sent: Tuesday, January 14, 2003 5:56 PM
> > Subject: RE: When any logged user has his own logger file
> >
> >
> > > Once a logger has been created, it is never destroyed.  You
> > will probably
> > > want to look at using MDC for user information instead of
> > created a new
> > > logger.  Look through the mail archives as there have been
> > many, many
> > > discussions about this before (it is an excellent candidate
> > topic for
> > adding
> > > to the Log4j Wiki documentation).  I don't know how you are
> > creating the
> > > log-file-per-user right now, but it should be a fairly
> > straightforward
> > > change to have that code look at the MDC values and create
> > file if needed
> > > (probably via a custom appender filter).
> > >
> > > hth,
> > > -Mark
> > >
> > > > -----Original Message-----
> > > > From: Krzysztof Krzos [mailto:[EMAIL PROTECTED]]
> > > > Sent: Tuesday, January 14, 2003 8:40 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: When any logged user has his own logger file
> > > >
> > > >
> > > > I use log4j for writing log for own files of any user which
> > > > is logging to my
> > > > application.
> > > > For each user i create category and to this category append
> > > > file. I use
> > > > log4j 1.1.3.
> > > > After users i logout or session is invalidated i can call
> > > > only shutdown()
> > > > for his category, but the problem is that category never
> > disappear.
> > > > After some days I have many categories that I can't throw
> > out them!
> > > > For example I have categories created after some minutes of work:
> > > >
> > > > beans.PaymentMgrBean
> > > > beans.ReportDatabaseBean
> > > > users.UsrLogger-admin-1042559345395
> > > > users.UsrLogger-fff-1042560011683
> > > > users.UsrLogger-admin-1042559653438
> > > > beans.ReportDatabaseSfBean
> > > > users.UsrLogger-kkk-1042559259702
> > > > users.UsrLogger-ddd-1042559224241
> > > > users.UsrLogger-guest-1042559646678
> > > > users.UsrLogger-admin-1042559987639
> > > > users
> > > > users.UsrLogger-admin-1042559193176
> > > >
> > > > after week I have hundreds categories!
> > > >
> > > > almost all Categories started from users.UsrLogger-* I want
> > > > to throw out.
> > > > There is any possibility?
> > > > There is no function to kill categories. In new version -
> > > > 1.2.7 also I can't
> > > > throw out created by myself loggers (previously
> > categories). I think.
> > > > regards
> > > > chris
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to