- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有全新安装的 tomcat。
为了改进日志记录,我编辑了 conf/logging.properties
。
换行
java.util.logging.ConsoleHandler.level = FINE
到
java.util.logging.ConsoleHandler.level = FINER
并附加行
org.apache.catalina.level = FINER
然后我启动服务器,如果我无法通过用户名 MyUsername
和 MyPassword
向 http://localhost:8080/manager/
进行身份验证> 我看到了这个输出:
FINE [http-bio-443-exec-2] org.apache.catalina.authenticator.AuthenticatorBase.invoke Security checking request GET /manager/html
FINE [http-bio-443-exec-2] org.apache.catalina.loader.WebappClassLoaderBase.loadClass loadClass(org.apache.catalina.manager.HTMLManagerServlet, false)
FINE [http-bio-443-exec-2] org.apache.catalina.loader.WebappClassLoaderBase.loadClass Delegating to parent classloader1 java.net.URLClassLoader@1218025c
FINE [http-bio-443-exec-2] org.apache.catalina.loader.WebappClassLoaderBase.loadClass Loading class from parent
FINE [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.findSecurityConstraints Checking constraint 'SecurityConstraint[Status interface]' against GET /html --> false
FINE [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.findSecurityConstraints Checking constraint 'SecurityConstraint[JMX Proxy interface]' against GET /html --> false
FINE [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.findSecurityConstraints Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against GET /html --> false
FINE [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.findSecurityConstraints Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against GET /html --> true
FINE [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.findSecurityConstraints Checking constraint 'SecurityConstraint[Status interface]' against GET /html --> false
FINE [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.findSecurityConstraints Checking constraint 'SecurityConstraint[JMX Proxy interface]' against GET /html --> false
FINE [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.findSecurityConstraints Checking constraint 'SecurityConstraint[Text Manager interface (for scripts)]' against GET /html --> false
FINE [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.findSecurityConstraints Checking constraint 'SecurityConstraint[HTML Manager interface (for humans)]' against GET /html --> true
FINE [http-bio-443-exec-2] org.apache.catalina.authenticator.AuthenticatorBase.invoke Calling hasUserDataPermission()
FINE [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.hasUserDataPermission User data constraint has no restrictions
FINE [http-bio-443-exec-2] org.apache.catalina.authenticator.AuthenticatorBase.invoke Calling authenticate()
FINER [http-bio-443-exec-2] org.apache.catalina.realm.RealmBase.authenticate Username MyUsername NOT successfully authenticated
FINE [http-bio-443-exec-2] org.apache.catalina.authenticator.AuthenticatorBase.invoke Failed authenticate() test
FINE [http-bio-443-exec-2] org.apache.catalina.core.StandardHostValve.custom Processing ErrorPage[errorCode=401, location=/WEB-INF/jsp/401.jsp]
FINER [http-bio-443-exec-2] org.apache.catalina.core.StandardWrapper.allocate Returning non-STM instance
FINE [http-bio-443-exec-2] org.apache.catalina.core.ApplicationDispatcher.doForward Disabling the response for futher output
FINE [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.session.ManagerBase.processExpires Start expire sessions StandardManager at 1525428004090 sessioncount 0
FINE [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.session.ManagerBase.processExpires End expire sessions StandardManager processingTime 4 expired sessions: 0
现在我修改步骤 2 并将包 realm
添加到定义中。现在第 2 步添加了这一行:
org.apache.catalina.realm.level = FINER
为什么 FINER-Loggings 消失了?我的意思是,org.apache.catalina.realm
更具体,对吧?
最佳答案
如果我的理解正确,您最终会得到如下所示的日志记录属性:
java.util.logging.ConsoleHandler.level = FINER
org.apache.catalina.realm.level = FINER
Java Logging Overview section 1.1状态:
Applications make logging calls on Logger objects. Loggers are organized in a hierarchical namespace and child Loggers may inherit some logging properties from their parents in the namespace.
当读取记录器名称时,父记录器位于点的左侧。因此,org.apache.catalina
是 org.apache.catalina.realm
的父级和 org.apache.catalina.core
.
执行代码代码必须为demand a logger为了让它存在。 简单地在属性文件中添加行不会创建记录器。如果创建了它们,它们将只是 garbage collected。反正。这意味着假设您有一个记录器树 A <- B <- C
.您要为 B
设置级别因此所有B
children 所以你加A.B.level
属性文件中的行。但是,在运行时,需要的记录器是 A
和 C
所以你需要处理的是"" <- A <- A.B.C
当你期待 "" <- A <- A.B <- A.B.C
综上所述,我认为您的记录器在运行时看起来像:
"" <- org.apache.catalina <- org.apache.catalina.realm.RealmBase
并且没有 Tomcat 代码创建一个名为 org.apache.catalina.realm
的实际记录器.
可以通过连接JConsole来验证运行 JVM 并检查 MBean 选项卡并列出记录器名称。在 Tomcat 上这将不起作用,因为返回的记录器取决于调用类加载器。
要解决此问题,您可以使用 config要求记录器并将其保存在内存中的选项。您只需在 system class path 上的自定义代码上安装它.
否则您必须在属性文件中指定所有已知的子记录器名称,这可能会很冗长。
First idea: If we look at the CSS specifity we know that .mydiv{ color:red} is not as specific as div.mydiv{color: green} so a div.mydiv contains text in red? Inheriance means if not specified what is anti-inheritance.
与 CSS 不同,JUL 有一个运行时记录器树和一个属性文件。当执行代码需要记录器时,运行时记录器树会动态调整。只有在代码需要记录器时才会使用这些属性。在属性文件中指定记录器名称并不意味着什么,除非记录器是由代码创建的。这可以更改记录器的父级,从而更改级别。试一试:
package so;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
public class TheMissingParent {
private static final Logger[] LAZY_ONE;
static {
LAZY_ONE = new Logger[] { Logger.getLogger("org.apache.catalina"),
Logger.getLogger("org.apache.catalina.realm.RealmBase") };
}
private static volatile Logger[] LAZY_TWO;
public static void main(String[] args) {
loadProperties();
printAncestors(LAZY_ONE);
findlLongLostParents();
System.out.println("====");
printAncestors(LAZY_ONE);
}
private static void loadProperties() {
Properties props = new Properties();
props.put("org.apache.catalina.realm.level", "FINER");
try(ByteArrayOutputStream out = new ByteArrayOutputStream()) {
props.store(out, "");
LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(out.toByteArray()));
} catch (IOException ioe) {
throw new AssertionError(ioe);
}
}
private static void findlLongLostParents() {
LAZY_TWO = new Logger[] {Logger.getLogger("org.apache.catalina.realm") };
}
private static void printAncestors(Logger[] loggers) {
// System.out.println(loggers.toString());
for (Logger l : loggers) {
printAncestors(l);
System.out.println();
}
}
private static void printAncestors(Logger l) {
if (l != null) {
printAncestors(l.getParent());
System.out.print("<-");
String name = l.getName();
if (name != null && name.isEmpty()) {
System.out.append("\"\"");
} else {
System.out.append(name);
}
for(Logger p = l; p != null; p = p.getParent()) {
Level lvl = p.getLevel();
if (lvl != null) {
System.out.append('{').append(lvl.getName()).append('}');
break;
}
}
}
}
}
这将输出:
<-""{INFO}<-org.apache.catalina{INFO}
<-""{INFO}<-org.apache.catalina{INFO}<-org.apache.catalina.realm.RealmBase{INFO}
====
<-""{INFO}<-org.apache.catalina{INFO}
<-""{INFO}<-org.apache.catalina{INFO}<-org.apache.catalina.realm{FINER}<-org.apache.catalina.realm.RealmBase{FINER}
这是核心问题。如果 Tomcat(或某些自定义代码)从不要求 org.apache.catalina.realm
logger 属性文件中的那一行只是死代码。
Second, if you say so, noone specified to org.apache.catalina nor org.apache nor org nor `` to be level INFO, so where would the value INFO came from?
描述了这种行为 in the LoggerManager class level docs :
If neither of these properties is defined then, as described above, the LogManager will read its initial configuration from a properties file "lib/logging.properties" in the JRE directory.
根记录器命名为空字符串""
是所有记录器的父级。始终创建根记录器。
关于Tomcat 日志记录困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50172433/
我有一个程序可以打开一个窗口并快速改变背景颜色并随机弹出矩形和椭圆形。我的代码有效,但我不知道为什么,因为我没有在我的代码中调用 repaint() 函数。当我使用我个人的 update() 函数包含
var allRapidSpells = $$('input[value^=RSW]'); 谁能告诉我这是做什么的? 最佳答案 我敢猜测您正在使用 MooTools ,一个 JavaScript 框架
我有一个抽象父类,它有多个子类。我希望 child 能够拥有一个对于该 child 的每个实例都相同的变量。我不想将构造函数传递给 child 来告诉它它的名字,因为当它可以被硬编码时,这看起来很愚蠢
我刚刚在 Git 存储库上做了一些糟糕的事情,我不知道如何解决这个问题。我什至不知道我是怎么把它弄成这样的……! 在存储库(托管在 git hub 上)上,有 3 个我感兴趣的分支:master、br
我是 GIT 的新手,在理解提交日志图时遇到问题。 我感觉每条平行线都是一个分支。虽然我的源代码只有 2 个分支。我在下面提供的提交日志图中看到 3-4 条平行线(Microsoft Team Ser
我是 WPF 的新手,ScrollViewer 让我很沮丧。要么我只是没有“得到”它,要么它是一种有限的控制。 这是我的挫折: 水平滚动错误 水平滚动条仅在列表底部可见(我必须滚动到底部才能看到) 坏
那么 $('table.selectable td.capable input:text') 比 $('table.selectable td input:text') 更好吗?换句话说,指定一个类会
我刚刚完成了计算机图形学类(class),我们必须对光线追踪器进行编程。尽管所有结果都是正确的,但我对 OpenMP 的使用感到困惑(顺便说一句,这不是类(class)的一部分)。我有这个循环(C++
与 PatternSynonyms ( explicitly bidirectional form ),pattern-to-expr 方程实际上形成了一个函数,但拼写为大写(假设您最终得到正确类型的
我是 javascript/coffeescript 新手。 有人可以解释一下为什么这个 CoffeeScript/JavaScript 会毫无延迟地快速通过吗?我对第一种情况的想法是,它是对 upd
如果我调用document.getElementsByClassName('cl'),我会得到一个 HTMLCollection。它似乎包含 Element 对象而不是 HTMLElement 对象,
这是我本月的 azure payasyougo 使用费用。 我很难理解为什么我要为标准中型应用服务付费,我认为它会包含在计算时间中?我只运行一个云服务,这对于一个没有做太多事情的云服务来说似乎有点陡峭
除了the issue I am already having之外,我还在I saw a video on it之后安装了HBase(尚未安装)之前,还安装了Zookeeper。在安装它时,我遇到了许
我正在将 XSLT 与 regexp:match exslt 函数一起使用。上述函数采用 JavaScript Regex 模式。因此,我尝试匹配一组数字 1 到 3 OR 5 到 7 OR 9 到
我想知道为什么这段代码会给出消息:SyntaxError:意外的标记其他。 var compare = function(choice1,choice2){ if(choice1===choice2)
我尝试使用复选框和 JQuery 过滤日历上的事件, $(document).ready(function () { $('.scrollable-menu :checkbox').click(f
假设我们有一个用户想要一个名为:“test/lasdhjal.txt”,无论如何。现在,如果我将其放入新的文件(输入)中;对象里面,它会认为 test/是一个文件夹,而它是名称的一部分。我能做什么呢?
问题是 stash 的更改不会留在我 stash 它们的分支中。其他分支存储将被覆盖示例: 我愿意: git checkout iss4 // made some changes gi
我是一个 java 新手,并且在 StackOverflow 错误/在类之间访问文件的能力方面遇到了一个非常令人困惑的问题。我知道根本原因可能是我进行了一些递归调用,但修复它的语法却让我无法理解。我认
public X createData(int n) { int[] values = new int[n]; Random rand = new Random(); for
我是一名优秀的程序员,十分优秀!