Slf4j LoggerFactory.getLogger和sonarqube [英] Slf4j LoggerFactory.getLogger and sonarqube

查看:548
本文介绍了Slf4j LoggerFactory.getLogger和sonarqube的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

初始化Slf4j LoggerFactory.getLogger的正确方法是什么?
我的代码中有

What is the correct way to initialize Slf4j LoggerFactory.getLogger? I have in my code

static final Logger logger = LoggerFactory.getLogger(MyClass.class);

但是,sonarqube代码分析将此代码标记为主要错误:
将此常量名重命名为匹配正则表达式'^ [AZ] [A-Z0-9] *(_ [A-Z0-9] +)* $'

But sonarqube code analysis marks this code as major error: "Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'"

有什么问题?

推荐答案

常量(静态最终)变量在Java中通常是大写的。所以你可以:

Constants (static final) variables are generally in upper case in Java. So you can either:


  • 在这种特殊情况下忽略评论(对记录器使用小型上限并不罕见)

  • logger 重命名为其他内容,例如 LOG

  • ignore the comment in this particular case (it is not unusual to use small caps for the logger)
  • rename logger into something else, for example LOG

这篇关于Slf4j LoggerFactory.getLogger和sonarqube的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆