Closed devinjparsons closed 11 years ago
Hi,
I've quickly tested the Threshold parameter and it works fine for me.
Here's the test-case:
log4j.properties file:
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.appender.A1.threshold=INFO
# Define the graylog2 destination
log4j.appender.graylog2=org.graylog2.log.GelfAppender
log4j.appender.graylog2.amqpURI=amqp://10.0.0.1
log4j.appender.graylog2.amqpExchangeName=messages
log4j.appender.graylog2.amqpRoutingKey=gelfudp
log4j.appender.graylog2.amqpMaxRetries=5
log4j.appender.graylog2.facility=test-application
log4j.appender.graylog2.layout=org.apache.log4j.PatternLayout
log4j.appender.graylog2.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%t] [%c{1}] - %m%n
log4j.appender.graylog2.additionalFields={'environment': 'DEV', 'application': 'MyAPP'}
log4j.appender.graylog2.extractStacktrace=true
log4j.appender.graylog2.addExtendedInformation=true
log4j.appender.graylog2.threshold=ERROR
# Send all INFO logs to graylog2
log4j.rootLogger=DEBUG, graylog2, A1
My assumptions are:
Java code to test it:
public class TestLog4j {
static Logger logger = Logger.getLogger(TestLog4j.class);
public static void main(String[] args) {
PropertyConfigurator.configure("log4j.properties");
logger.info("> test info");
logger.debug("> test debug");
logger.error("> test error");
logger.error("> test error");
logger.error("> test error");
logger.error("> test error");
logger.error("> test error");
logger.error("> test error");
}
}
After running the scenario above I see following picture in Graylog2:
and in the console:
0 [main] INFO com.test.TestLog4j - > test info
1 [main] ERROR com.test.TestLog4j - > test error
573 [main] ERROR com.test.TestLog4j - > test error
574 [main] ERROR com.test.TestLog4j - > test error
576 [main] ERROR com.test.TestLog4j - > test error
577 [main] ERROR com.test.TestLog4j - > test error
578 [main] ERROR com.test.TestLog4j - > test error
As per my expectations.
Did I miss something?
Thanks, Anton
Thanks for the reply, it looks like i was too quick to think it wasn't working. My installation is working as expected, I found a rogue application that didn't get the threshold update.
Thanks again for your help.
Devin
On Fri, Aug 30, 2013 at 7:08 AM, Anton Yakimov notifications@github.comwrote:
Hi,
I've quickly tested the Threshold parameter and it works fine for me.
Here's the test-case:
log4j.properties file:
A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n log4j.appender.A1.threshold=INFO
Define the graylog2 destination
log4j.appender.graylog2=org.graylog2.log.GelfAppender log4j.appender.graylog2.amqpURI=amqp://10.0.0.1 log4j.appender.graylog2.amqpExchangeName=messages log4j.appender.graylog2.amqpRoutingKey=gelfudp log4j.appender.graylog2.amqpMaxRetries=5 log4j.appender.graylog2.facility=test-application log4j.appender.graylog2.layout=org.apache.log4j.PatternLayout log4j.appender.graylog2.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%t] [%c{1}] - %m%n log4j.appender.graylog2.additionalFields={'environment': 'DEV', 'application': 'MyAPP'} log4j.appender.graylog2.extractStacktrace=true log4j.appender.graylog2.addExtendedInformation=true log4j.appender.graylog2.threshold=ERROR
Send all INFO logs to graylog2
log4j.rootLogger=DEBUG, graylog2, A1
My assumptions are:
- Console appender will display messages INFO and above
- Graylog2 appender will do the same but from ERROR
Java code to test it:
public class TestLog4j {
static Logger logger = Logger.getLogger(TestLog4j.class); public static void main(String[] args) { PropertyConfigurator.configure("log4j.properties"); logger.info("> test info"); logger.debug("> test debug"); logger.error("> test error"); logger.error("> test error"); logger.error("> test error"); logger.error("> test error"); logger.error("> test error"); logger.error("> test error"); }}
After running the scenario above I see following picture in Graylog2:
[image: untitled]https://f.cloud.github.com/assets/3533/1057477/b6598640-1174-11e3-9307-124dc1ba7b1b.png
and in the console:
0 [main] INFO com.test.TestLog4j - > test info 1 [main] ERROR com.test.TestLog4j - > test error 573 [main] ERROR com.test.TestLog4j - > test error 574 [main] ERROR com.test.TestLog4j - > test error 576 [main] ERROR com.test.TestLog4j - > test error 577 [main] ERROR com.test.TestLog4j - > test error 578 [main] ERROR com.test.TestLog4j - > test error
As per my expectations.
Did I miss something?
Thanks, Anton
— Reply to this email directly or view it on GitHubhttps://github.com/t0xa/gelfj/issues/63#issuecomment-23559613 .
Happy to help! Closing.
I see in the log4j.xml example you can set the threshold, I added this parameter to my log4j.properties file but it doesn't seem to be honoring that. Is this parameter supported?