Moocar / logback-gelf

Logback plugin to send GELF messages to graylog2 server
Apache License 2.0
147 stars 59 forks source link

Startup suceeds even if exception is thrown #33

Closed danfin closed 10 years ago

danfin commented 10 years ago

In GelfAppender.initExecutor, let's say an exception is thrown. (This isn't the bug, but I don't see any logging of this, perhaps a sysout can be added?)

But in start(), when initExecutor() was called, super.start() has already been called, which means that the startup was successful.

The order of the two statements in start() should be reversed, like this:

@Override public void start() { initExecutor(); super.start(); }

so that start() won't be called when exception occurs.

Moocar commented 10 years ago

Hey, I just tried forcing an error in initExecutor() and the following error was printed out. Are you sure you just haven't configured a root logger for level ERROR?

21:43:19,334 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@14:14 - RuntimeException in Action for tag [appender] java.lang.RuntimeException: Error initialising appender appenderExecutor
    at java.lang.RuntimeException: Error initialising appender appenderExecutor
    at  at me.moocar.logbackgelf.GelfAppender.initExecutor(GelfAppender.java:115)
    at  at me.moocar.logbackgelf.GelfAppender.start(GelfAppender.java:78)
    at  at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96)
    at  at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:318)
    at  at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:197)
    at  at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:183)
    at  at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
    at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:147)
    at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:133)
    at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:96)
    at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:55)
    at  at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
    at  at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
    at  at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
    at  at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:54)
    at  at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
    at  at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
    at  at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
    at  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
    at  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
    at  at me.moocar.logbackgelf.IntegrationTest.test(IntegrationTest.java:60)
    at  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at  at java.lang.reflect.Method.invoke(Method.java:597)
    at  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
    at  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
    at  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at  at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
    at  at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at  at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at  at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at  at java.lang.reflect.Method.invoke(Method.java:597)
    at  at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at  at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at  at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at  at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at  at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.Exception: Expected exception
    at  at me.moocar.logbackgelf.GelfAppender.initExecutor(GelfAppender.java:111)
    at  ... 50 common frames omitted
Moocar commented 10 years ago

@danfin Ping