SpringBoot中本身支持lockback 所以不需要引用任何依赖 而需要做如下步骤 配置日志更丰富更简单
第一 创建lockback xml文件 eg logback-prd.xml
第二 配置文件中(application.properties) 添加日志路径配置 eg:logging.config=classpath:logback-prd.xml
实例:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="org/springframework/boot/logging/logback/base.xml"/> <appender name="ELK" class="com.cwbase.logback.RedisAppender"> <host>192.168.1.17</host> <port>6379</port> <key>avc-smarterm-api-server-log</key> </appender> <root level="ERROR"> <appender-ref ref="CONSOLE" /> </root> <logger name="org.springframework" additivity="false" level="ERROR"> <appender-ref ref="CONSOLE" /> </logger> <logger name="org.xnio" additivity="false" level="ERROR"> <appender-ref ref="CONSOLE" /> </logger> <logger name="io.undertow" additivity="false" level="ERROR"> <appender-ref ref="CONSOLE" /> </logger> <logger name="org.hibernate" additivity="false" level="ERROR"> <appender-ref ref="CONSOLE" /> </logger> <logger name="o.apache.commons.httpclient" additivity="false" level="ERROR"> <appender-ref ref="CONSOLE" /> </logger> <logger name="httpclient.wire" additivity="false" level="ERROR"> <appender-ref ref="CONSOLE" /> </logger> <logger name="o.a.c.h.params" additivity="false" level="ERROR"> <appender-ref ref="CONSOLE" /> </logger> <logger name="com.avcdata" additivity="false" level="DEBUG"> <appender-ref ref="ELK" /> <appender-ref ref="CONSOLE" /> </logger> </configuration>
实例详解:
<appender name="ELK" class="com.cwbase.logback.RedisAppender">
代表 日志输出到redis 服务器
拓展 :如果是几十台的集群 看日志的话 每台服务器登入查看日志麻烦 而使用上述方法将所有的日志输出到redis 进而+logstash服务器的input 提取 汇总 并进入ElasticSearch搜索服务器 结合Kibana软件查看日志比较合适 详情查看http://blog.csdn.net/kmtong/article/details/38920327
详情参考:
https://my.oschina.net/looly/blog/298675
http://www.cnblogs.com/zcy_soft/p/3567613.html