Yes, my application is using Logback for logging.
I just got my application working properly and found out what the actual
problem. My problem is I can't seem to get Tomcat and my application
logging to Graylog simultaneously. Only configuring Tomcat to log to
Graylog works, and only configuring my application to log to Graylog works,
so they do work individually. When I add logging to Graylog to Tomcat, my
application logs stop showing up in Graylog. The changes I'm making to
Tomcat are:
- logging properties
- adding biz.paluch.logging.gelf.jul.GelfLogHandler to handlers
- adding biz.paluch.logging.gelf.jul.GelfLogHandler to .handlers
- adding properties
biz.paluch.logging.gelf.jul.GelfLogHandler.level = INFO
biz.paluch.logging.gelf.jul.GelfLogHandler.host = udp:10.0.x.x
biz.paluch.logging.gelf.jul.GelfLogHandler.port = 12201
- catalina.sh
- adding the following:
CLASSPATH=$CLASSPATH:$CATALINA_BASE/bin/logstash-gelf-1.8.0.jar:$CATALINA_BASE/bin/json-simple-1.1.1.jar:$CATALINA_BASE/bin/jedis-2.8.0.jar:$CATALINA_BASE/bin/commons-pool2-2.4.2.jar
I did get 2 versions of my application working simultaneously too, so there
isn't a problem with multiple applications.
I'm using maven to build my app, and tried to change the scope of
logstash-gelf to provided, but that didn't work (class not found exception
in the app).
I'm assuming it's a library/classpath problem. Any ideas on how to resolve
the problem?
Thanks.
On Mon, Feb 1, 2016 at 3:24 AM, Jochen Schalanda <[email protected]> wrote:
> Hi Eric,
>
> are you sure that your application is using Logback for logging and that
> the GELF appender(s) have been put in the correct location on disk to be
> loaded on the JVM classpath?
>
> Apache Tomcat itself is using a fork of the Apache Commons Logging library
> (see https://tomcat.apache.org/tomcat-8.0-doc/logging.html) which is
> using the logging facilities of the Java SE standard libraries (
> java.util.logging) by default.
>
>
> Cheers,
> Jochen
>
> On Friday, 29 January 2016 22:26:46 UTC+1, Eric Smith wrote:
>>
>> Hi,
>>
>> We have several existing Java based web apps (tomcat), and we're using
>> logback for logging locally. Now I'm trying to get the log entries sent
>> using UDP to a Graylog2 server, but I'm not having any luck. I have tomcat
>> logs showing up in Graylog2 using logstash (ex. Server startup in 32674
>> ms), so I'm confident Graylog2 is working. I've tried several different
>> handlers and used their example logback.xml:
>>
>> - https://github.com/mp911de/logstash-gelf
>> - https://github.com/Moocar/logback-gelf
>> - https://github.com/pukkaone/logback-gelf
>>
>> Example logback.xml (logstash):
>>
>> <!DOCTYPE configuration>
>>
>> <configuration>
>> <contextName>test</contextName>
>> <jmxConfigurator/>
>>
>> <appender name="gelf"
>> class="biz.paluch.logging.gelf.logback.GelfLogbackAppender">
>> <host>udp:10.0.x.x</host>
>> <port>12201</port>
>> <version>1.1</version>
>> <facility>java-test</facility>
>> <extractStackTrace>true</extractStackTrace>
>> <filterStackTrace>true</filterStackTrace>
>> <mdcProfiling>true</mdcProfiling>
>> <timestampPattern>yyyy-MM-dd HH:mm:ss,SSSS</timestampPattern>
>> <maximumMessageSize>8192</maximumMessageSize>
>>
>> <!-- This are static fields -->
>>
>> <additionalFields>fieldName1=fieldValue1,fieldName2=fieldValue2</additionalFields>
>> <!-- Optional: Specify field types -->
>>
>> <additionalFieldTypes>fieldName1=String,fieldName2=Double,fieldName3=Long</additionalFieldTypes>
>>
>> <!-- This are fields using MDC -->
>> <mdcFields>mdcField1,mdcField2</mdcFields>
>> <dynamicMdcFields>mdc.*,(mdc|MDC)fields</dynamicMdcFields>
>> <includeFullMdc>true</includeFullMdc>
>> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
>> <level>TRACE</level>
>> </filter>
>> </appender>
>>
>> <root level="TRACE">
>> <appender-ref ref="gelf" />
>> </root>
>> </configuration>
>>
>> Is there a simple example application (or web app) that works that I can
>> download and try? I'd like to get working source code so that I can verify
>> my setup and then figure out what I'm doing wrong.
>>
>> Thanks.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Graylog Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/graylog2/ilvoYFoCFPA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/graylog2/a498d5e1-6218-4e1f-9f04-82db41391dc0%40googlegroups.com
> <https://groups.google.com/d/msgid/graylog2/a498d5e1-6218-4e1f-9f04-82db41391dc0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Graylog Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/graylog2/CAForO8KQ5HiQ5dZC1RhkQhRTEyVVHWv6nWHLibYk-aqPSTNp8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.