Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JBoss AS 7: Logging

I struggle a bit with JBoss AS7 and the logging. I cannot find anything related on the web despite the fact that my issue is a very general one.

The default log looks currently like this:

11:57:29,950 INFO  [stdout] (http--0.0.0.0-8081-78) 248408930 [http--0.0.0.0-8081-78] INFO  org.apache.http.impl.client.DefaultHttpClient  - I/O exception (java.net.SocketException) caught when processing request: Connection reset
11:57:29,950 INFO  [stdout] (http--0.0.0.0-8081-78) 248408930 [http--0.0.0.0-8081-78] INFO org.apache.http.impl.client.DefaultHttpClient  - Retrying request

notice the [stdout], those lines where written to stout by some logging library which is used by some library and picked up by JBoss and written to the log file. This is what i want to fix.

I guess there must be a way to have an adapter which tells log4j (or any other logging framework) to log to the jboss logging subsystem?

My first idea was to remove all log4j configuration from the classpath of my project. I found one in a library i use which did log to stdout. But this does not fix anything.

11:21:01,648 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
11:21:01,648 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) log4j:WARN Please initialize the log4j system properly.
11:21:01,648 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

The usual error message when no appender is configured. At least i can be sure that no configuration is in the classpath anymore.

The JBoss AS documentation does not even mention this kind of scenario, how i am supposed to use 3rd party libraries when i am not able to get proper logging?

I really hope someone can help me out, any hint is appreciated!

Malax

like image 706
Malax Avatar asked Mar 19 '12 11:03

Malax


People also ask

What are the logging levels in JBoss?

By default, JBoss produces output to both the console and a log file ( log/server. log ). There are six basic log levels in log4j: TRACE , DEBUG , INFO , WARN , ERROR and FATAL .

How do I change the log level in JBoss EAP 7?

You can use the web console or CLI to easily do this which will not require a restart. In CLI it's simply /subsystem=logging/root-logger=ROOT:write-attribute(name=level, value=INFO) .

Is JBoss logging Log4j?

JBoss AS uses log4j as logging framework. This tutorial will show how to configure log4j service in your jBoss application server and also how to create a custom configuration which can be deployed along with your application. Log4j is a flexible open source project from Apache.


1 Answers

While it's not in the question, I do assume you are attempting to use log4j with JBoss AS7. If that is true and you do need to use appenders, then you need to exclude the log4j that comes with the server and package your own version with your deployment currently. This should be changing soon once AS7-514 is resolved. Once that feature is added, nothing will need to be done on your side.

To resolve the issue for now you first need to create a jboss-deployment-structure.xml that should look like the following:

<jboss-deployment-structure>
    <deployment>
        <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
        <exclusions>
            <module name="org.apache.log4j" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

Then add your own version of log4j to your WEB-INF/lib directory or any other place where the deployment would be able to find the library.

After that it should work just as you would expect.

like image 115
James R. Perkins Avatar answered Sep 22 '22 09:09

James R. Perkins