Log4j disk access or queue

P

Philippe Godin

Good day,

The client requirements indicates that the logging of messages shall
be done physically (write to disk) ONLY every 10 seconds or when 100
log messages are pending. Understand the ONLY word clearly, the
application we're building is to run on a custom board that uses a 1GB
compact flash card as the rom. The information that is to be kept on
the card is really CRUCIAL. There's a lot of computation involve and
write to disk shall be reduced to a minimum. Is there a way to use
log4j to do so. I've checked the documentation and couldn't find
anything that realized that. I would first need something like a log
queue and find a way to manage the physical access to disk. I could
create the classes that would accomplish this but just wanted to make
sure log4j doesn't already handle this. BTW, we have to be using a
RollingFile of 100MB (probably 10 times 10MB)

Any idea??
thx, Flip
 
O

Oscar kind

Philippe Godin said:
The client requirements indicates that the logging of messages shall
be done physically (write to disk) ONLY every 10 seconds or when 100
log messages are pending. Understand the ONLY word clearly, the
application we're building is to run on a custom board that uses a 1GB
compact flash card as the rom. The information that is to be kept on
the card is really CRUCIAL. There's a lot of computation involve and
write to disk shall be reduced to a minimum. Is there a way to use
log4j to do so. I've checked the documentation and couldn't find
anything that realized that. I would first need something like a log
queue and find a way to manage the physical access to disk. I could
create the classes that would accomplish this but just wanted to make
sure log4j doesn't already handle this. BTW, we have to be using a
RollingFile of 100MB (probably 10 times 10MB)

You cannot use log4j directly, but you can either:
- Create a service that listens on a socket and writes all messages
conform the requirements. Use log4j to log to the socket.
- Create your own subclass of (Rolling)FileAppender that writes the
messages according to the requirements.


Oscar
 
P

Philippe Godin

Thx Oscar for your time and patience,

I met the client requirements by creating a new class that is pretty
much like the AsynchAppender. It handles the management of all
appenders and put new log events into the boundedFIFO list. Upon log
event reception by this new class, a check is made to ensure that the
maximum load hasn't been reached. In our case it's 100. If so, the
list is flushed to all registered appenders for immediate processing.
Otherwise the event is appended to the list. I've modified the
Dispatcher to make it sleep for 10 seconds. Every time it runs, it
flushes the content of the list to all registered appenders no matter
how many events are in there.

Philippe Godin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top