- Index all log4net messages directly to Elasticsearch
- Compatible with .NET 4+
- Use either the direct insert or bulk Elasticsearch API for improved efficiency and performance
- Log to a single index or automatically create rolling daily indices
- No dependencies (other than log4net)
- Fully open source, MIT licensed
- Convenient installation via Nuget (see below)
PM> Install-Package log4net.elasticsearch
Elasticsearch Log Document Example
{ "_index": "log-2016.02.12", "_type": "logEvent", "_id": "AVLXHEwEJfnUYPcgkJ5r", "_version": 1, "_score": 1, "_source": { "timeStamp": "2016-02-12T20:11:41.5864254Z", "message": "Something broke.", "messageObject": { }, "exception": { "Type": "System.Exception", "Message": "There was a system error", "HelpLink": null, "Source": null, "HResult": -2146233088, "StackTrace": null, "Data": { "CustomProperty": "CustomPropertyValue", "SystemUserID": "User43" }, "InnerException": null }, "loggerName": "log4net.ES.Example.Program", "domain": "log4net.ES.Example.vshost.exe", "identity": "", "level": "ERROR", "className": "log4net.ES.Example.Program", "fileName": "C:\\projects\\log4net.ES.Example\\log4net.ES.Example\\Program.cs", "lineNumber": "26", "fullInfo": "log4net.ES.Example.Program.Main(Program.cs:26)", "methodName": "Main", "fix": "LocationInfo, UserName, Identity, Partial", "properties": { "log4net:Identity": "", "log4net:UserName": "JToto", "log4net:HostName": "JToto01", "@timestamp": "2016-02-12T20:11:41.5864254Z" }, "userName": "JToto", "threadName": "9", "hostName": "JTOTO01" } }
Samples & Documentation
log4net.ElasticSearch comes with comprehensible documentation, examples, and a sample project which can be downloaded or cloned directly from Github. Check out the GETTING STARTED section to learn about configuration options and performance considerations. Happy logging!
-
Getting Started contains a further explanation of the configuration options.
-
The examples section has several
log4net
configuration options which you can use to tweak the way messages are logged to Elasticsearch.
Contributing & Copyright
log4net.ElasticSearch is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding code or functionality, please also add unit and integration tests.
log4net.ElasticSearch is available under the MIT license, which allows modification and redistribution for both commercial and non-commercial purposes. This web site / template is borrowed and modified from the FSProjects Scaffolding repository because I find it quite nice and convenient for users. They do some great work over there. Consider using the Paket package manager for some of your work.