Skip to content

Instantly share code, notes, and snippets.

@mp911de
Last active August 29, 2015 14:01
Show Gist options
  • Save mp911de/7c00ad719a39e1124f4e to your computer and use it in GitHub Desktop.
Save mp911de/7c00ad719a39e1124f4e to your computer and use it in GitHub Desktop.
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/server.log"/>
<param name="Append" value="false"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<!-- Rollover at the top of each hour
<param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
-->
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
<!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>
<!-- =========================== -->
<!-- Append messages to logstash -->
<!-- =========================== -->
<appender name="GelfLogger" class="biz.paluch.logging.gelf.log4j.GelfLogAppender">
<param name="Threshold" value="INFO"/>
<param name="Host" value="<Your Logstash Host>"/>
<param name="Facility" value="JBoss 4"/>
<param name="ExtractStackTrace" value="true"/>
<param name="FilterStackTrace" value="true"/>
<param name="MdcProfiling" value="true"/>
<param name="AdditionalFields" value="Environment=Test"/>
<param name="MdcFields" value="remoteAddr,remoteUser,sessionId,requestUri,requestMethod"/>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="SERVER_LOG"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="GelfLogger"/>
</root>
</log4j:configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment