为什么 logback 允许通过设置为 INFO 级别的根记录器进行 DEBUG 输出?
上下文是一个使用 Hibernate 的 spring-boot-starter 项目。在版本 1.2.0 中,POM 命名为 logback-classic 和 logback-core。以下配置文件位于其类路径 (src/main/resources) 中,将根记录器设置为 INFO 级别。
logback-test.xml:
<configuration scan="true" debug="false">
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/test.log</file>
<encoder>
<pattern>%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="FILE" />
</root>
<logger name="org.hibernate.SQL" level="DEBUG" />
</configuration>
Run Code Online (Sandbox Code Playgroud)
在 JUnit 测试期间,文件中会出现大量 INFO/WARN/ERROR 消息。但我很惊讶地看到 org.hibernate.SQL 的以下 DEBUG 输出,这是唯一提供调试级输出的包。我想我必须将根记录器设置为 DEBUG 级别才能允许这样做;我认为 INFO 级别会阻止它:
2018-09-18T13:31:02.596Z [http-nio-auto-1-exec-4] DEBUG o.h.SQL - delete from C_NOTIF_XYZ where ID=?
Run Code Online (Sandbox Code Playgroud)
在幕后,Hibernate 似乎通过注释使用 org.jboss.logging.Logger,请参阅https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate /内部/CoreLogging.java
由于使用了注释,我不确定是否找到了创建上面所示的删除输出的确切类。我通过谷歌搜索发现,有些人建议进行日志填充类的交互;但我不确定。 …
我正在分析一些非常密集的数字时间测量.我想获得平均值,标准偏差等一些投入都很大,所以我想我会避免造成数以百万计的数字列表,而是使用Python collections.Counter对象作为一个紧凑的表示.
示例:我的一个小输入产生collection.Counter类似值[(48, 4082), (49, 1146)],这意味着值48的4,082次出现和值49的1,146次出现.对于此数据集,我手动计算平均值为48.2192042846.
当然,如果我有一个简单的4,082 + 1,146 = 5,228个整数列表,我会把它提供给numpy.mean().
我的问题:如何从collections.Counter对象中的值计算描述性统计数据,就像我有一个数字列表一样?我是否必须创建完整列表或是否有快捷方式?
我有一个基于 Spring-Boot 版本 1.5.4.RELEASE 的 REST-only 微服务,带有 spring-boot-starter-security。该服务没有网页,只有 JSON 输入和输出。用户名和密码在 application.properties 文件中配置。归功于http://ryanjbaxter.com/2015/01/06/securing-rest-apis-with-spring-boot/,以下配置使服务器很好地实现了基本的 HTTP 身份验证,它接受凭据并拒绝未经授权的要求:
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests() //
.anyRequest().authenticated().and().httpBasic();
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我想从基本的 HTTP 身份验证中排除一个小的 ole 路径,一个小的端点。从疯狂的谷歌搜索和复制粘贴我修改了上面的内容:
http.csrf().disable().authorizeRequests() //
.antMatchers("/healthcheck").permitAll()
.anyRequest().authenticated().and().httpBasic();
Run Code Online (Sandbox Code Playgroud)
这会在没有警告的情况下编译和运行,但不会为未经身份验证的访问打开该路径。我仍然必须提供凭据来检查服务运行状况。
我必须一一匹配路径吗?我的小健康检查端点位于上下文路径的基础上,还有一大堆其他端点 - 逐个添加路径会很麻烦。
我的 application.properties 文件的相关部分是:
security.user.name = web-user
security.user.password = web-pass
management.security.roles=SUPERUSER
Run Code Online (Sandbox Code Playgroud)
也许我需要以某种方式摆弄角色?
请帮忙,提前致谢。
更新 1:
路径信息 - 我希望这条路径(以及更多根路径)受到保护:
localhost:8081/abcd/user
Run Code Online (Sandbox Code Playgroud)
而且我只希望打开这一条路径,无需身份验证:
localhost:8081/abcd/healthcheck
Run Code Online (Sandbox Code Playgroud)
更新 2:看起来我在很大程度上重复了这个 3 年前的问题,但没有为我的问题接受答案: