Logging exception stacktrace using syslog handler in JBoss EAP 6/7

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.2+
    • 7.x

Issue

How to log exception stacktrace using syslog handler ?

Resolution

To capture complete stack trace a custom handler configuration is needed. See below the CLI command to generate a sample:

/subsystem=logging/custom-handler=SYSLOG:add(class="org.jboss.logmanager.handlers.SyslogHandler",module="org.jboss.logmanager",formatter="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E",properties={"serverHostname"=>"localhost","facility"=>"LOCAL_USE_6","syslogType"=>"RFC5424"}

For domain environment, just add the /profile=<profileName> preffix to the CLI command.

The XML configuration added will be similar to the one below:

<custom-handler name="SYSLOG" class="org.jboss.logmanager.handlers.SyslogHandler" module="org.jboss.logmanager">
 <level name="INFO"/>
 <formatter>
     <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E"/>
 </formatter>
 <properties>
  <property name="serverHostname" value="localhost"/>
  <property name="facility" value="LOCAL_USE_6"/>
  <property name="syslogType" value="RFC5424"/>
 </properties>
</custom-handler>

Result expected with this configuration is to see the stack trace logged in log file:

- java[606] 10:01:55,689 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.web.connector.http: org.jboss.msc.service.StartException in service jboss.web.connector.http: JBAS018007: Error starting web connector#012#011at org.jboss.as.web.WebConnectorService.start(WebConnectorService.java:358)#012#011at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]#012#011at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]#012#011at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_37]#012#011at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_37]#012#011at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_37]#012Caused by: LifecycleException:  JBWEB000023: Protocol handler initialization failed#012#011at org.apache.catalina.connector.Connector.init(Connector.java:986)#012#011at org.jboss.as.web.WebConnectorService.start(WebConnectorService.java:300)#012#011... 5 more#012

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments