java - Log4j Does not Send Mail unless Thread.sleep -
i having problem log4j
, sending notification emails.
my log4j.properties
log4j.appender.mail=org.apache.log4j.net.smtpappender log4j.appender.mail.threshold=error log4j.appender.mail.buffersize=512 log4j.appender.mail.smtphost=10.10.10.10 log4j.appender.mail.from=team@domain.com log4j.appender.mail.subject=subject here log4j.appender.mail.to=team@domain.com log4j.appender.mail.layout=org.apache.log4j.patternlayout log4j.appender.mail.layout.conversionpattern=%d{yyyy/mm/dd hh:mm:ss,sss} [%t] %-5p %c %x - %m%n
the program caused error when trying send , email made log.error()
test it.
i tested code below, still did not send emails.
public static void main(string[] args) { log.error("error "); }
when add thread.sleep
in above code. works!
public static void main(string[] args) throws exception{ log.error("error "); thread.sleep(1000000l); }
the problem main thread
exits , causes mail sending thread
terminate. decided change program wait(not exit) until log4j sending mails completely. have no idea how mail-sending status in log4j.
any appreciate.
try set buffersize value 1, maybe logger waiting full buffer before sending
Comments
Post a Comment