Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement springboot to write logs to elk

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to achieve springboot to elk to write a log, the editor feels very practical, so share with you to learn, I hope you can learn something after reading this article, say nothing, follow the editor to have a look.

Connect to the logstash in elk in springboot, then write the log with the specified index index, then use kibana to query and analyze the log, and use elasticsearch to save the log.

Add referenc

Implementation 'net.logstash.logback:logstash-logback-encoder:5.3'

Add configuration

% d {yyyy-MM-dd HH:mm:ss.SSS} [% thread]%-5level% logger {50} -% msg% n 127.0.0.1 logger 5000 {"appname": "elkDemo"}

Specify configuration

Server.port=81logging.config=classpath:logback-spring.xml

Logstash configuration Index

Input {tcp {port = > 5000 codec = > "json"} # # Add your filters / logstash plugins configuration hereoutput {elasticsearch {hosts = > "elasticsearch:9200" user = > "elastic" password = > "changeme" index = > "% {[appname]}"}}

Build an index in kibana

Index through the kiban menu: Management > Index patterns > Create index pattern, where the available index names are displayed.

The above is how to achieve springboot to write logs to elk. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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: 0

*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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report