4

In a previous version of Jboss I was able to configure a SYSLOG appender with the following configuration in jboss-log4j.xml:

<appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
  <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
  <param name="Facility" value="LOCAL7"/>
  <param name="FacilityPrinting" value="true"/>
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
  </layout>
</appender>

Now I've upgraded to Jboss AS 7 and it seems like this should go in the $JBOSS_HOME/standalone/configuration/standalone.xml but the syntax is different.

My question is: How do I configure Jboss AS 7 to use a SYSLOG appender?

Jarred Olson
  • 3,075
  • 1
  • 19
  • 34

5 Answers5

8

log4j is no longer used in JBoss AS 7 there for there is no syslog appender. You would have to find or develop a custom java.util.logging.Handler if you want something similar.

Once the handler is created it's probably best to make it a module. Let's say the handler was called com.example.logging.SysLogHandler. In $JBOSS_HOME/modules create a directory called com/example/logging/main. In that directory place your library and create an module.xml file, see another module for an example.

module.xml example:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.example.logging">
    <resources>
        <resource-root path="sys-log.jar"/>
    </resources>
    <dependencies>
         <!-- Insert any dependencies here like the example below -->
         <!-- <module name="org.jboss.logmanager"/> -->
    </dependencies>
</module>

You can now edit the standalone.xml to add a custom handler.

<subsystem xmlns="urn:jboss:domain:logging:1.1">
    ...
    <!-- A syslog handler -->
    <custom-handler name="syslog" class="com.example.logging.SysLogHandler" module="com.example.logging">
        <level name="INFO"/>
        <formatter>
            <pattern-formatter pattern="%d{MMM dd HH:mm:ss} %-5p [%c] (%t) %s%n"/>
        </formatter>
        <properties>
            <!-- Set any properties that can accessed through setter methods -->
            <property name="autoFlush" value="true"/>
        </properties>
    </custom-handler>
    ...
    <root-logger>
        <level name="INFO"/>
        <handlers>
            <handler name="CONSOLE"/>
            <handler name="FILE"/>
            <handler name="syslog"/>
        </handlers>
    </root-logger>
</subsystem>
James R. Perkins
  • 16,800
  • 44
  • 60
  • After I write my own/find a Syslog Handler how do I configure it in the standalone.xml? Where do I put the jar file? $JBOSS_HOME/standalone/lib/ext? – Jarred Olson May 01 '12 at 17:22
  • You would use a `'. I'll update the answer with an example. Deciding where to put it really depends on how you want to use it. The approach I would take is probably make it a module. – James R. Perkins May 01 '12 at 20:19
  • Are you guys planning to provide a syslog appender out of the box in future releases of jboss as 7? – feniix Jul 24 '12 at 19:30
  • @feniix There is no specific plan at this point, but we are thinking about it if we can find the time. It would be added to the JBoss Log Manager so that anyone using the log manager could use it. – James R. Perkins Jul 24 '12 at 20:36
  • JBoss AS 7.2/EAP 6 have added syslog-handler. See [details](https://docs.jboss.org/author/display/AS72/Logging+Configuration#LoggingConfiguration-sysloghandler) – vim Oct 27 '14 at 14:48
1

Here is one simple implementation of a LogHandler that simply delegates to log4j SyslogAppender. http://randomtekkstuff.blogspot.in/2013/03/jboss-as-7-syslog-handler.html. Can be deployed as a jboss module

yoda
  • 11
  • 2
0

I had the same problem, and starting with the answers above I implemented a version on my own. Together with the configuration files you can find my solution at Github

RobinHood
  • 10,897
  • 4
  • 48
  • 97
kifj
  • 1
0

You can use old style Appender from Log4j since version 7.2.x of JBoss AS.

See https://issues.jboss.org/browse/AS7-4925 for details

vim
  • 407
  • 4
  • 8
0

JBoss AS 7.2 has syslog handler, so you can use:

<syslog-handler name="SYSLOG">
    <level name="DEBUG" />
    <server-address value="<syslog.server>"/>
    <port value="<syslog.port>"/>
</syslog-handler>

...

<root-logger>
    <handlers>
    ...
        <handler name="SYSLOG" />
    ...
    </handlers>
</root-logger>

More info in documentation: https://docs.jboss.org/author/display/AS72/Admin+Guide#AdminGuide-sysloghandler

Slawomir Jaranowski
  • 7,381
  • 3
  • 25
  • 33