Weblogic managed server isn't logging errors properly

2.4k views Asked by At

I'm working with a managed WebLogic server, and noticed that errors weren't appearing in the stdout.log file the way that it should be. Regular sysouts are showing up, but anything that happens within a catch block (after an Exception is thrown) is actually appearing at the TOP of the stdout.log file.

Here's the test code that I am running to replicate this issue:

...
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.");
...

Here's what the log looks like AFTER I execute that code (only showing relevant content):

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.

Can anyone explain to me why it's overwriting from the top when logging errors? Also it seems like there's a config file missing, that it's creating on the fly. Is that something that could be causing this issue?

I'd like for all stdout and stderr to go to the same log file, and simply append new log output to the end of the file, and currently I can't figure out how to do that.

Thanks and regards,

Brandon

1

There are 1 answers

1
Mohab Elsayed On

Regarding redirecting the JVM output in weblogic to the same log file, you may use the following JVM flag: -Dweblogic.log.RedirectStdoutToServerLogEnabled=true

Quoting from the document:

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.

Please refer to this doc for more info: http://docs.oracle.com/cd/E13222_01/wls/docs92/logging/config_logs.html#wp1008455

Regards, Mohab