jjchiw / gelf4net

GELF log4net Appender - graylog2
MIT License
63 stars 59 forks source link

Added async appenders #27

Closed wjdavis5 closed 8 years ago

wjdavis5 commented 8 years ago

New Appenders

Async implementations of both appenders. The async impl uses a ConcurrentQueue and a dedicated appender thread to perform logging. We found this greatly increased throughput in our production applications by making the calls to log return virtually instantly. The async versions simply extend their sync couterparts, overriding the calls to append.

Updated dependencies

Upgraded to the latest version of all dependencies.

wjdavis5 commented 8 years ago

Hello just wondered if you had any comments on this. Thanks.

jjchiw commented 8 years ago

Hi, yes I'm planning to merge the request and this(https://github.com/jjchiw/gelf4net/pull/29) one tonight and remove the Debug.WriteLine (https://github.com/jjchiw/gelf4net/pull/25)

Run some tests and generate the nuget package.....

Thanks.

jjchiw commented 8 years ago

I'm testing AsyncGelfUdpAppender and it seems is not logging, I'm using the examples project that are in the repo another thing that I noticed it's that the application it doesn't close. I created a branch (https://github.com/jjchiw/gelf4net/tree/async-appenders) that I will look for it during the day

dheygere commented 8 years ago

Hello, this is obviously not the same feature as the one in this PR, but I just wanted to let you know that there is another project that lets any appender be Async: https://github.com/cjbhaines/Log4Net.Async

wjdavis5 commented 8 years ago

Hrm. I'll take a look to see whats going on too

jjchiw commented 8 years ago

@uttg I tested the Async Appender and it works with <param name="IncludeLocationInformation" value="false" /> it seems the message.File = loggingEvent.LocationInformation.FileName; LocalInformation is null...

I'm testing (AsyncForwardingAppender) using SimpleConsoleApplication and it has the same problem that the implementation AsyncGelfUdpAppender it seems it doesn't exit the application.

And I also tested ParallelForwardingAppender and this one it does exit the application.

About the implementation of AsyncGelfUdpAppender and AsyncGelfAmqpAppender I don't know why it's not logging the events. I'll give it a try tomorrow

:)

jjchiw commented 8 years ago

Ok, I found the error, it seems that if IncludeLocationInformation is set as true the gelfmessage is sent like this

{
  "facility": "RandomPhrases",
  "file": "?",
  "host": "host",
  "level": 7,
  "line": "?",
  "timestamp": "1448360742.04914",
  "version": "1.0",
  "LoggerName": "SimpleConsoleApplication.Program",
  "full_message": "[3] Program - Randomizer Sentence: yay",
  "short_message": "[3] Program - Randomizer Sentence: yay",
  "_app": "RandomSentence",
  "_version": "1.0",
  "_Environment": "Dev",
  "_Level": "DEBUG"
}

The line property with the character ? it's what graylog doesn't like MapperParsingException[failed to parse [line]]; nested: NumberFormatException[For input string: "?"];

Ok, so, what do you think?

The issue that when we use Async~Appenders and the Console (SimpleConsoleApplication) doesn't close, will check it later

wjdavis5 commented 8 years ago

Could you send me the example app you are using to test with that isnt closing? We are using this in production today and not having this issue.

Thanks,

jjchiw commented 8 years ago

I'm using SimpleConsoleApplication that exists in the repository https://github.com/jjchiw/gelf4net/tree/master/examples