Skip to content

Java Logging

Michael Calmer edited this page Jun 25, 2024 · 6 revisions

How to Configure Logging for the Java Processes

Original author: Abid Mehmood

Introduction

Using '''log4j''' it is generally possible to set log levels for certain Java packages and specific classes separately. In order to do that, add a line as above per package or class, but specify the exact package or class with the same syntax as well as the desired log level. This is valid for all log4j config files we talk about here.

Further note that whenever the logging configuration is changed for one of the components, that specific component needs to be restarted using ''rctomcat restart'', ''rctaskomatic restart'' or ''rcrhn-search restart'' respectively in order to see the effect of the changes.

Tomcat

The main logfile of the SUSE Manager web application is this one (stdout of the tomcat process):

/var/log/rhn/rhn_web_ui.log

Logging for the web application is configured in this file:

/usr/share/susemanager/www/tomcat/webapps/rhn/WEB-INF/classes/log4j2.xml

Note that possibly this file doesn't exist on your server, in this case please copy the https://github.com/uyuni-project/uyuni/blob/master/java/code/src/log4j2.xml config file from git. In order to enable general DEBUG logging (very noisy!), just uncomment:

<Logger name="com.redhat.rhn" level="debug" />
<Logger name="com.suse" level="debug" />

This would set the DEBUG log level for all the ''com.redhat.rhn'' and ''com.suse'' Java package, specify any subpackage or Java class here in order to adapt the logging to your needs. The following lines for instance would enable logging for all the content sync related code, setup wizard and HTTP code respectively:

<Logger name="com.redhat.rhn.manager.content" level="debug" />
<Logger name="com.redhat.rhn.manager.setup" level="debug" />
<Logger name="com.redhat.rhn.common.util.http" level="debug" />

Taskomatic

The taskomatic logfile can be found here:

/var/log/rhn/rhn_taskomatic_daemon.log

Logging for the taskomatic process is configured in this file:

/usr/share/rhn/classes/log4j2.xml

In order to enable general DEBUG logging (very noisy!), just uncomment:

<Logger name="com.redhat.rhn" level="debug" />
<Logger name="com.suse" level="debug" />

Rotation settings can be changed editing the following file:

/usr/share/rhn/config-defaults/rhn_taskomatic_daemon.conf

Search Server

The logfile for the search server (''rhnsearchd'') is to be found here:

/var/log/rhn/search/rhn_search.log

Note that all logging of the search server is also forwarded to rhn_search_daemon.log inside the same folder. Logging for the search server is configured by placing a configuration file at this URI (file and folder do not exist initially!):

/usr/share/rhn/search/classes/log4j.xml

The search server https://github.com/uyuni-project/uyuni/blob/master/search-server/spacewalk-search/src/config/log4j.xml log4j config file from git should be used as a starting point and can be further customized. In order to enable general DEBUG logging, please add this line in there:

<Logger name="com.redhat.satellite" level="debug" >
    <AppenderRef ref="SearchAppender" />
</Logger>

How to configure Java Debugger Ports

On a containerized Uyuni, you also need to open the debug ports from the container in the service file You can adapt /etc/systemd/system/uyuni-server.service.d/Service.conf and change the PODMAN_EXTRA_ARGS in the environment

Environment="PODMAN_EXTRA_ARGS=-p 8001:8001 -p 8002:8002 -p 8003:8003"

Call systemctl daemon-reload after this modification and restart the container.

Tomcat

$> echo 'JAVA_OPTS=" $JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=*:8003,server=y,suspend=n "' > /etc/tomcat/conf.d/remote_debug.conf

Taskomatic

$> echo 'JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=*:8001,server=y,suspend=n "' > /etc/rhn/taskomatic.conf

Search Daemon

$> echo "JAVA_OPTS='-Xdebug -Xrunjdwp:transport=dt_socket,address=*:8002,server=y,suspend=n'" >> /usr/share/rhn/config-defaults/rhn_search_daemon.conf
Clone this wiki locally