DLade
DLade

Reputation: 63

JBoss AS 7: Logging to remote host (logstash)

While it seems easy to configure log4j to send the logs to a remote host (log4j: How to use SocketAppender?) I can't find any way to do the same at JBoss' (7.1.1) standalone.xml.

I found a way to replace the JBOss configuration to stricly use own log4j (JBoss AS 7: Logging) but then the remote switching of log levels will be lost - and for a live system this is no option.

Upvotes: 0

Views: 3490

Answers (2)

mp911de
mp911de

Reputation: 18119

Alternatively, you could use logstash-gelf in order to send your log messages to logstash (using GELF). You're more flexible when it comes to custom fields/MDC data. You need an additional module, in order to make it work: http://search.maven.org/#artifactdetails%7Cbiz.paluch.logging%7Clogstash-gelf%7C1.3.2%7Cjar

        <custom-handler name="GelfLogger" class="biz.paluch.logging.gelf.jboss7.JBoss7GelfLogHandler" module="biz.paluch.logging">
            <level name="INFO"/>
            <properties>
                <property name="graylogHost" value="somehost"/>
                <property name="extractStackTrace" value="true"/>
                <property name="filterStackTrace" value="true"/>
                <property name="mdcProfiling" value="true"/>
                <property name="facility" value="JBoss Core"/>
                <property name="additionalFields" value="Environment=AT"/>
                <property name="mdcFields" value="Application,App.Version,remoteAddr,remoteUser,sessionId,requestUri,requestMethod,requestParams,Tracking.RootUser,Tracking.RootSessionId,Tracking.RootRequestId,WS.last.Request,WS.last.Response,WS.last.Endpoint"/>
            </properties>
        </custom-handler>

Upvotes: 1

lifeonatrip
lifeonatrip

Reputation: 1

If updating to 7.2 is an option, you can use the syslog-handler in jboss as 7.2 , I use it in production with excellent results. Take a look at https://docs.jboss.org/author/display/AS72/Logging+Configuration

It will look like:

            <syslog-handler name="SYSLOG">
                <level name="INFO"/>
                <hostname value="${jboss.bind.address}"/>
                <app-name value="JbossAS7"/>
                <server-address value="1.2.3.4"/>
            </syslog-handler>

Is compliant with RFC-5424 and RFC-3164 as you can configure the facility in it.

Upvotes: 0

Related Questions