gpt4 book ai didi

java - Weblogic 托管服务器未正确记录错误

转载 作者:行者123 更新时间:2023-11-30 03:22:31 24 4
gpt4 key购买 nike

我正在使用托管 WebLogic 服务器,并注意到错误没有按应有的方式出现在 stdout.log 文件中。常规的系统输出正在显示,但 catch block 内发生的任何事情(抛出异常之后)实际上都出现在 stdout.log 文件的顶部。

这是我运行来复制此问题的测试代码:

...
System.out.println("Testing error logging...");

try {
throw new Exception();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

System.out.println("error thrown.");
...

这是我执行该代码后日志的样子(仅显示相关内容):

JAVA Memory arguments: -Xms512m -Xmx512m -XX:CompileThreshold=8000 -XXjava version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled in the future
Jun 23, 2015 12:13:10 PM org.apache.axis.configuration.EngineConfigurationFactoryServlet getServerEngineConfig
**SEVERE: Unable to find config file. Creating new servlet engine config file: /WEB-INF/server-config.wsdd**
java.lang.Exception
at ErrorLoggingTest.doGet(ErrorLoggingTest.java:33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3594)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
th Java version:
Starting WLS with line:

...

(lots of logging in between, from the WebLogic server startup process)

...

Testing error logging...

error thrown.

任何人都可以向我解释为什么在记录错误时它会从顶部覆盖吗?另外,似乎缺少一个配置文件,它是动态创建的。这是否可能导致此问题?

我希望所有 stdout 和 stderr 都转到同一个日志文件,并简单地将新的日志输出附加到文件末尾,目前我不知道如何做到这一点。

感谢和问候,

布兰登

最佳答案

关于将 weblogic 中的 JVM 输出重定向到同一日志文件,您可以使用以下 JVM 标志:-Dweblogic.log.RedirectStdoutToServerLogEnabled=true

引自文档:

The JVM in which a WebLogic Server instance runs, sends messages to standard error and standard out. Server as well as application code write directly to these streams instead of using the logging mechanism. Through a configuration option, you can redirect the JVM output to all the registered log destinations, like the server terminal console and log file. When enabled, a log entry appears as a message of NOTICE severity.

请参阅此文档了解更多信息:http://docs.oracle.com/cd/E13222_01/wls/docs92/logging/config_logs.html#wp1008455

问候,莫哈卜

关于java - Weblogic 托管服务器未正确记录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31008529/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com