You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Christoph Macheiner <Ch...@update.com> on 2007/12/04 22:41:32 UTC

multi-user logger

hi...

i am currently trying to incorporate log4cxx into our multi-user
software. basically it is working well, but there is demand for more
extensive configuration (instead of our "fixed" configuration). the wish
is as follows: each user can work with different modules and/or
different logins, and all users/modules are serviced by one single
process (the single user/module per process scenario would of course be
no problem). assume, i want to use loggers named MODULE_NAME.USER_NAME
that should be configured dynamically from a single configuration file
(i use the domconfigurator).

the problem is, for example, with file appenders. there can be hundreds
of user/module combinations, but they can be grouped into a few
different loggers that need to be parametrized at runtime (like filename
should be MODULE_NAME.USER_NAME.log for one group, but only
MODULE_NAME.log for others etc).

the coolest thing would be to have the xml configuration file as a
"template" and create all loggers at runtime from that template xml.
then i could dynamically replace the filenames (etc) and/or reuse
already configured loggers for users of the same group. i cannot really
"hard-configure" all the loggers in the configuration file because, as i
mentioned, there could possibly be hundreds of different files.

so, is there a way to create all my loggers at runtime, from an xml
document provided on the fly? or is there an easier solution...

any help is greatly appreciated (and sorry for the long post). thanks
very much, christoph.

Re: multi-user logger

Posted by Curt Arnold <ca...@apache.org>.
On Dec 4, 2007, at 3:41 PM, Christoph Macheiner wrote:

> hi...
>
> i am currently trying to incorporate log4cxx into our multi-user
> software. basically it is working well, but there is demand for more
> extensive configuration (instead of our "fixed" configuration). the  
> wish
> is as follows: each user can work with different modules and/or
> different logins, and all users/modules are serviced by one single
> process (the single user/module per process scenario would of course  
> be
> no problem). assume, i want to use loggers named MODULE_NAME.USER_NAME
> that should be configured dynamically from a single configuration file
> (i use the domconfigurator).
>
> the problem is, for example, with file appenders. there can be  
> hundreds
> of user/module combinations, but they can be grouped into a few
> different loggers that need to be parametrized at runtime (like  
> filename
> should be MODULE_NAME.USER_NAME.log for one group, but only
> MODULE_NAME.log for others etc).
>
> the coolest thing would be to have the xml configuration file as a
> "template" and create all loggers at runtime from that template xml.
> then i could dynamically replace the filenames (etc) and/or reuse
> already configured loggers for users of the same group. i cannot  
> really
> "hard-configure" all the loggers in the configuration file because,  
> as i
> mentioned, there could possibly be hundreds of different files.
>
> so, is there a way to create all my loggers at runtime, from an xml
> document provided on the fly? or is there an easier solution...
>
> any help is greatly appreciated (and sorry for the long post). thanks
> very much, christoph.


There isn't anything in the current code base of log4cxx or log4j that  
would address that issue.  However, it does sound up the alley of the  
hypothetical log4j MultiFileAppender.  If you search the log4j-dev  
mailing list, you will see a lot of postings discussing such a beast.   
Some of the building blocks were sketched out in the log4j "sandbox",  
but didn't evolve to the point of a usable appender.  I've had good  
intentions to get back to developing it since issues that would  
benefit from it come up frequently, but I can develop less code than I  
can imagine and didn't get much feedback or assistance.

Basically, the idea is that an MFA could manage a constrained set of  
open file handles where the destination of a logging request would be  
based on an examination of the LoggingEvent.  An MFA could be used to  
put all messages from a specific thread, or of a specific level, or of  
a specific time frame, etc, into a specific file and would not need to  
close off other open files (which causes problems with the  
RollingFileAppender's since they close before open and can't recover  
if they can't open a new file).

In your scenario, the file name strategy for the MFA could examine the  
logging event and use the user name (which could be stored in the MDC)  
and the module name (extracted from the logger name?) to generate the  
file name and the MFA would be responsible for managing the files.

Once developed for log4j, it should be fairly simple to port to  
log4cxx.  However, there has been no activity on it for many, many  
months.



RE: multi-user logger

Posted by "Steck, David" <da...@lmco.com>.
Christoph,

If the different settings are per module, then you could just configure
the logger for each module, and all user-specific sub-loggers would
inherit those properties.

If it's not that simple, maybe you could use the log4cxx API function
calls in your program to configure your loggers?  That would be more
flexible than the configuration file.

Or, perhaps you could configure a generic logger in the configuration
file, and then a portion of your program would attempt to duplicate that
logger's setting, modifying them as needed.

Just a thought.  If you found a way to solve your problem, let us know
how you did it, in case someone later wants to do something similar.

-David Steck
david.steck@lmco.com


-----Original Message-----
From: Christoph Macheiner [mailto:Christoph.Macheiner@update.com] 
Sent: Tuesday, December 04, 2007 4:42 PM
To: log4cxx-user@logging.apache.org
Subject: multi-user logger

hi...

i am currently trying to incorporate log4cxx into our multi-user
software. basically it is working well, but there is demand for more
extensive configuration (instead of our "fixed" configuration). the wish
is as follows: each user can work with different modules and/or
different logins, and all users/modules are serviced by one single
process (the single user/module per process scenario would of course be
no problem). assume, i want to use loggers named MODULE_NAME.USER_NAME
that should be configured dynamically from a single configuration file
(i use the domconfigurator).

the problem is, for example, with file appenders. there can be hundreds
of user/module combinations, but they can be grouped into a few
different loggers that need to be parametrized at runtime (like filename
should be MODULE_NAME.USER_NAME.log for one group, but only
MODULE_NAME.log for others etc).

the coolest thing would be to have the xml configuration file as a
"template" and create all loggers at runtime from that template xml.
then i could dynamically replace the filenames (etc) and/or reuse
already configured loggers for users of the same group. i cannot really
"hard-configure" all the loggers in the configuration file because, as i
mentioned, there could possibly be hundreds of different files.

so, is there a way to create all my loggers at runtime, from an xml
document provided on the fly? or is there an easier solution...

any help is greatly appreciated (and sorry for the long post). thanks
very much, christoph.