0
votes

guys I met a problem.I use logg4j and apache-flume to collect logs.the architecture is use logg4j remote print,the config like this:

log4j.appender.flume=org.apache.flume.clients.log4jappender.Log4jAppender
  log4j.appender.flume.Hostname=192.168.152.49
  log4j.appender.flume.Port=44446
  log4j.appender.flume.layout=org.apache.log4j.PatternLayout

while the configure of flume like this:

 a1.sources.r1.type=avro
 a1.sources.r1.bind=192.168.152.49
 a1.sources.r1.port=44446

it works!but the question is when the flume closed.the application which use logg4j can't print log!so is anybody can tell me. how to fix this problem

1

1 Answers

0
votes

It depends on how you want to handle Flume being down. With the regular Log4jAppender, you can enable unsafe mode which will log the error in the log4j LogLog, but otherwise fail silently. To do that you can set log4j.appender.flume.UnsafeMode = true. You can see an example here:

https://github.com/kite-sdk/kite-examples/blob/master/logging/src/main/resources/log4j.properties#L20

With unsafe enabled, any events you log while Flume is down will be lost.

If you want to be able to point to multiple Flume agents and have it balance the load between them as well as fail over if one of them goes down, you can use the LoadBalancingLog4jAppender instead. The docs here should help:

http://flume.apache.org/FlumeUserGuide.html#load-balancing-log4j-appender