In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what is the method of loh4j integrating flume". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the method of loh4j integrating flume".
1. Configure to start flume
① flume configuration file conf/flume-conf.properties (this file is usually flume-conf.properties.default). You can copy and modify the suffix.
The configuration file is as follows:
Agent1.channels = ch2
Agent1.sources = avro-source1
Agent1.sinks = log-sink1
# define channel
Agent1.channels.ch2.type = memory # mem channel
# define source
Agent1.sources.avro-source1.channels = ch2
Agent1.sources.avro-source1.type = avro # avro source
Agent1.sources.avro-source1.bind = 0.0.0.0
Agent1.sources.avro-source1.port = 41414
# define sink
Agent1.sinks.log-sink1.channel = ch2
Agent1.sinks.log-sink1.type = logger # logger sink
Start flume
Bin/flume-ng agent-conf conf--conf-file conf/flume-conf.properties-name agent1-Dflume.root.logger=INFO,console
II. Configuration of log4j
① adds flume appender to the log4j.properties file
Log4j.rootLogger=INFO,flume # log level, info and flume
Log4j.appender.flume = org.apache.flume.clients.log4jappender.Log4jAppender
Log4j.appender.flume.Hostname = 192.168.57.133 # flume address
Log4j.appender.flume.Port = 41414 # Port on which flume source listens
Log4j.appender.flume.UnsafeMode = true
Log4j.appender.flume.layout=org.apache.log4j.PatternLayout
Log4j.appender.flume.layout.ConversionPattern=%d {yyyy-MM-dd HH:mm:ss,SSS} [% t] [% c] [% p] -% m% n
III. Testing
Add flume appender dependencies in maven
Org.apache.flume.flume-ng-clientsflume-ng-log4jappender1.6.0
Write a simple test class:
Public class Log4jTest {Logger logger = LoggerFactory.getLogger (Log4jTest.class) / * Test flume * @ Title: flumeTest * @ Description: TODO * @ param * @ return void * @ throws * / @ Test public void flumeTest () throws Exception {while (true) {logger.info ("spider", System.currentTimeMillis ()) Try {Thread.sleep (1000);} catch (Exception e) {/ / TODO: handle exception e.printStackTrace ();}
By running the test class, you can see the output of flume on the console
Thank you for your reading, the above is the content of "what is the method of loh4j integrating flume". After the study of this article, I believe you have a deeper understanding of what the method of loh4j integration of flume is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 218
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.