The best bet for both cases is to write a RepositorySelector that selects the LoggerRepository based on criteria you define. The most common cases of repository selectors are ones based on classloader (which can cause classloading issues unless you are *really* careful about it) or JNDI. I'm sure a few other implementations have been done as well. See what you can come up with. And, if you would, report back and let us know whether you succeeded.

Jake

At 07:10 PM 2/21/2006 +0000, you wrote:
>Winston Huang <weiqingh <at> mail.com> writes:
>
>>
>> hi there,
>>
>> i have a java program that behaves like a cron job which kicks off
>> jobs based on certain conditions. each job is implemented by a a
>> Runnable. i would like to have each job use a different log file. the
>> best i can do so far is to set NDC for the Runnable or print out the
>> thread name in the output. but all the logs still go to the same
>> file. it's more convenient if each job can write to a different log
>> file, identified by the job name for example. is there any way to do
>> it?
>>
>> note that each Runnable can invoke other common classes which in turn
>> use log4j inside. e.g. Runnable1 may call Util.foo, and Runnable2 may
>> call Util.foo as well. the logging output from Util.foo should go to
>> different log files based on the Runnable. however Util.foo uses the
>> static logger that's assoicated with the Util class itself.
>>
>> any help is greatly appreciated.
>> Winston
>>
>
>
>I have this problem too... Any luck figuring this out?
>
>This is the same issue as one program spawning multiple threads and wanting to
>direct the logging of each thread to a unique and dedicated log file.
>
>Seem's Log4j definitely supports logging control within a specific package
>hierarchy... that is you can control packages at various levels. But what if
>you want to control at the thread (lightweight or heavyweight) level - usually
>spanning many, many disparate packages?
>
>    Kev.
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to