bruno-garcia / log4net.ElasticSearch

log4net appender to ElasticSearch
https://bruno-garcia.github.io/log4net.ElasticSearch/
Other
220 stars 92 forks source link

Adding Log4Net.ElasticSearh via Nuget #45

Closed wpearson4 closed 9 years ago

wpearson4 commented 9 years ago

Good Morning,

I have added the package to my project via nuget. I am receiving the following error when trying to log the first time: Could not create Appender [ElasticSearchAppender] of type [log4net.ElasticSearch.ElasticSearchAppender, log4net.ElasticSearch]. Reported error follows. System.IO.FileNotFoundException: Could not load file or assembly 'log4net.ElasticSearch' or one of its dependencies. The system cannot find the file specified. File name: 'log4net.ElasticSearch'.

I can see the assembly referenced in references. It is references as log4net.ElasticSearch40

jptoto commented 9 years ago

@wpearson4 Can you post your log4net configuration here? It would be your app.config or your separate log4net xml config file. Whichever you're using.

wpearson4 commented 9 years ago

I have fixed the problem. I need to change the reference to the following: appender name="ElasticSearchAppender" type="log4net.ElasticSearch.ElasticSearchAppender, log4net.ElasticSearch.Net40"

One last question currently I send json serialized string as the message. It appears though elasticsearch only recognizes it as a string. Does log4net.elasticsearch support sending the message as json

jptoto commented 9 years ago

@wpearson4 glad you got it working! That's what I was going to look for if you posted your config here.

For adding custom information to the message object, I would highly recommend using a custom exception class which is a very common practice. You can see an example of how to do that here: https://gist.github.com/jptoto/9be57ce2fe253eb96739

Then the ES docs will look like this and you can query on them the same way: unnamed