由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - How to ues log4j to send log email in the multithreaded processes as similiar with single-threaded
相关主题
Question about Tomcatquestion on single thread & multithread
Re: 想起几年前Re: run servlet from command li如何让两个socket并行执行thread
如何动态改变log4j的log level啊a Java MultiThreading question
问个java logger的问题Basic thread question
怎么练习java multithread怎么可以练习多线程编程呢?
multi-threading guru们 (转载)求问如何学习multithreading
怎么学multithreading/concurrency?java concurrency (转载)
Re: Help!!! Java in Unix. Thread. I need exit and ls concurrently runn[转载] apache mod_jk.so 问题
相关话题的讨论汇总
话题: thread话题: xxxxxxx话题: module话题: time话题: log4j
进入Java版参与讨论
1 (共1页)
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.

1 (共1页)
进入Java版参与讨论
相关主题
[转载] apache mod_jk.so 问题怎么练习java multithread
如何让一个package使用另一个package的sourcemulti-threading guru们 (转载)
问个 maven multi-module project dependency 的问题怎么学multithreading/concurrency?
Re: How to lock a file and detect a thread is over?Re: Help!!! Java in Unix. Thread. I need exit and ls concurrently runn
Question about Tomcatquestion on single thread & multithread
Re: 想起几年前Re: run servlet from command li如何让两个socket并行执行thread
如何动态改变log4j的log level啊a Java MultiThreading question
问个java logger的问题Basic thread question
相关话题的讨论汇总
话题: thread话题: xxxxxxx话题: module话题: time话题: log4j