l*****b 发帖数: 82 | 1 My current system is single-threaded with several modules which are
processed in sequence. I use SMTPAppender to capture error and send warning
emails with the following format:
[time][thread-1][module 1]start: XXXXXXX
[time][thread-1][module 2]XXXXXXX
[time][thread-1][module 3]XXXXXXX
[time][thread-1][module 4]ERR: XXXXXXX
After I change the system to multhithreaded, the logs will be tangled up
like:
[time][thread-1][module 1]start: XXXXXXX
[time][thread-2][module 1]start: XXXXXXX
[time][thread | g*****g 发帖数: 34805 | 2 You either create logger per thread, or maybe extend SMTPAppender and
filter the log the way you want.
warning
【在 l*****b 的大作中提到】 : My current system is single-threaded with several modules which are : processed in sequence. I use SMTPAppender to capture error and send warning : emails with the following format: : [time][thread-1][module 1]start: XXXXXXX : [time][thread-1][module 2]XXXXXXX : [time][thread-1][module 3]XXXXXXX : [time][thread-1][module 4]ERR: XXXXXXX : After I change the system to multhithreaded, the logs will be tangled up : like: : [time][thread-1][module 1]start: XXXXXXX
| l*****b 发帖数: 82 | 3 Thanks, goodbug. Those are good advice. I have some questions on them:
For logger per thread, will it impact the performance? Provided thread pool
max is 200, there are about 200 logger at some time.
For customed SMTPAppender, how many buffer should I set? If threads
increased, it has chance the fixed buffer cannot reach the first log entry. | A**o 发帖数: 1550 | 4 question: how do you capture error and remembers the previous log event?
or how many emails you receive in the single thread mode in your example?
warning
【在 l*****b 的大作中提到】 : My current system is single-threaded with several modules which are : processed in sequence. I use SMTPAppender to capture error and send warning : emails with the following format: : [time][thread-1][module 1]start: XXXXXXX : [time][thread-1][module 2]XXXXXXX : [time][thread-1][module 3]XXXXXXX : [time][thread-1][module 4]ERR: XXXXXXX : After I change the system to multhithreaded, the logs will be tangled up : like: : [time][thread-1][module 1]start: XXXXXXX
| l*****b 发帖数: 82 | 5 Hi,Amao, I use SMTPAppender. It has a buffer setting to record specific
number of log events. My setting in single thread mode is 10. When error
occurs, one email is send out with 10 events. | A**o 发帖数: 1550 | 6 thanks for explaining. but i doubt the logger per thread
model would work without make your own extentions.
anyway, i don't think your request is what log4j intends to do.
and from my experience, tempering with log4j other than config is not worthy.
how about dump everything into a db using jdbc appender,
and assign each thread with a uid and log it.
and when an error occurs,
dig the db, and query on the uid, and send your email?
【在 l*****b 的大作中提到】 : Hi,Amao, I use SMTPAppender. It has a buffer setting to record specific : number of log events. My setting in single thread mode is 10. When error : occurs, one email is send out with 10 events.
|
|