You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Daniel Carvalho <dc...@finibanco.pt> on 2006/06/30 12:27:59 UTC

multiple files 2


Daniel:
>>> But this wouldn't work, because all loggers would use the same
>>> instance of FileTreeAppender, but i want their outputs to go to
>>> different files. One
>>> solution would be the "FileTreeAppender.doAppend" method choose the
>>> file based in LoggingEvent.getLoggerName(), but this would be very slow.
>>>
>

Curt Arnold wrote:
>> All you would be adding is a get() on a hash map to map logger name
>> with to get an OutputStream for each call to doAppend.  The cost of
>> mapping logger name to stream will be trivial compared to actual file
>> io.  You would end up having an open OutputStream around for every
>> encountered log name until the end of the appenders lifetime, but I
>> don't know if you had a chance to work around that in any other approach.


Boris:
>There could be a workaround: The information about the logger name is
>part of each log entry. You could easily write a script which splits
>up one big log file into several others at your choice.
>Why do you need that? You cannot see the flow of the application after
>splitting the log.
>This is the wrong list for this discussion. It belongs to log4-users.

thanks,

Let me explain my project. I'm creating a new logger object each time a user enters the application, and redirect it to file like
"appname/username.log". The logger should be closed when the user sessions expires.

How can i close a Logger object? i only know how to remove the associated appenders...

Another problem is that the DailyRollingFileAppender never renames the file if the logger is no longer used.

It seems this is not the usual way to use Log4j... Has log4j been designed for this kind of usage?

Instead i would have a single Logger object, and a field in each line with the username, and use external program to parse the files, as Boris
suggested.

daniel



__________________________________________________

Esta mensagem e quaisquer ficheiros anexos são confidenciais, destinando-se
ao uso exclusivo da pessoa e/ou entidade a que se dirigem. Caso não se lhe
destine, ou não seja responsável pelo seu encaminhamento ao destinatário,
informamos que a recebeu por engano. Qualquer utilização, distribuição,
reencaminhamento ou outra forma de revelação a terceiros, impressão ou
cópia são expressamente proibidos; sendo que agradecemos que destrua a
mensagem de imediato, informando o seu emissor ou o Finibanco do sucedido.
Não obstante o Finibanco utilizar software anti-vírus como precaução, não é
possível garantir que a presente mensagem e eventuais ficheiros anexos não
contêm vírus, pelo que não consideramos da responsabilidade desta
instituição eventuais consequências inerentes. Alerta-se, ainda, que as
mensagens transmitidas por este meio podem ser interceptadas, corrompidas,
perdidas, destruídas ou entregues com atraso ao destinatário.




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org