-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MarkZither/dev
First working version
- Loading branch information
Showing
13 changed files
with
499 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,74 @@ | ||
# Log4net.Appender.InfluxDBSyslog | ||
Log4net appender that posts events to InfluxDB in Syslog format | ||
|
||
| Branch | Status | | ||
| -------- | -------------- | | ||
|Master Branch|[![Build status](https://ci.appveyor.com/api/projects/status/dvouxggnqka0ptso/branch/master?svg=true)](https://ci.appveyor.com/project/MarkZither/Log4net.Appender.InfluxDBSyslog/branch/master)| | ||
|Dev Branch|[![Build status](https://ci.appveyor.com/api/projects/status/dvouxggnqka0ptso/branch/dev?svg=true)](https://ci.appveyor.com/project/MarkZither/Log4net.Appender.InfluxDBSyslog/branch/dev)| | ||
|
||
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Log4net.Appender.InfluxDBSyslog&metric=alert_status)](https://sonarcloud.io/dashboard?id=Log4net.Appender.InfluxDBSyslog) | ||
|
||
|
||
## How to setup | ||
### NuGet Package | ||
Install from nuget | ||
``` | ||
PM> Install-Package Log4net.Appender.InfluxDBSyslog | ||
``` | ||
|
||
or | ||
``` | ||
dotnet add package Log4net.Appender.InfluxDBSyslog --version 0.1.0-alpha0020 | ||
``` | ||
|
||
### Configure the appender | ||
``` xml | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<configSections> | ||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> | ||
</configSections> | ||
<log4net> | ||
<appender name="InfluxAppender" type="Log4net.Appender.InfluxDBSyslog.InfluxAppender, Log4net.Appender.InfluxDBSyslog"> | ||
<Scheme>http</Scheme> | ||
<Host>localhost</Host> | ||
<RemotePort>8086</RemotePort> | ||
<AppName>Console Test</AppName> | ||
<Facility>Console Test Custom Facility</Facility> | ||
</appender> | ||
<root> | ||
<level value="INFO" /> | ||
<appender-ref ref="InfluxAppender" /> | ||
</root> | ||
</log4net> | ||
</configuration> | ||
``` | ||
|
||
### InfluxDB and Chronograf | ||
Download InfluxDB 1.7 from [influxdata.com](https://portal.influxdata.com/downloads/) | ||
|
||
Run influxd and chronograf and see your logs flowing in. | ||
![syslog data in Chronograf](docs/img/Chronograf_Syslog_From_Log4net.png) | ||
|
||
### Dependencies | ||
|
||
- log4net | ||
- InfluxData.net | ||
|
||
### Building the project | ||
|
||
dotnet build | ||
|
||
## Contribute | ||
|
||
If you have any idea for an improvement or found a bug, do not hesitate to open an issue. | ||
|
||
## Thanks | ||
|
||
[Get Your Syslog On](https://www.influxdata.com/blog/get-your-syslog-on/) | ||
[Writing Logs Directly to InfluxDB - DZone](https://dzone.com/articles/writing-logs-directly-to-influxdb) | ||
|
||
|
||
## License | ||
|
||
Log4net.Appenders.Fluentd is distributed under MIT License. |
19 changes: 18 additions & 1 deletion
19
...es/Log4net.Appender.InfluxDBSyslog.Console/Log4net.Appender.InfluxDBSyslog.Console.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<Configurations>Debug;Release;DebugWithPackageGeneration</Configurations> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>0.1.0-alpha14</Version> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="log4net.config" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="log4net.config"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Log4net.Appender.InfluxDBSyslog\Log4net.Appender.InfluxDBSyslog.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
89 changes: 86 additions & 3 deletions
89
Samples/Log4net.Appender.InfluxDBSyslog.Console/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,95 @@ | ||
using System; | ||
using log4net; | ||
using log4net.Config; | ||
using System; | ||
using System.Reflection; | ||
using System.Threading; | ||
|
||
namespace Log4net.Appender.InfluxDBSyslog.Console | ||
namespace Log4net.Appender.InfluxDBSyslog.ConsoleTest | ||
{ | ||
class Program | ||
{ | ||
private static readonly ILog log = LogManager.GetLogger(typeof(Program)); | ||
static void Main(string[] args) | ||
{ | ||
System.Console.WriteLine("Hello World!"); | ||
// Set up a simple configuration that logs on the console. | ||
// Thanks Stackify https://stackify.com/making-log4net-net-core-work/ | ||
var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); | ||
XmlConfigurator.Configure(logRepository, new System.IO.FileInfo("log4net.config")); | ||
//BasicConfigurator.Configure(logRepository); | ||
Console.WriteLine("Hello World!"); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
log.Warn("Warn Console"); | ||
log.Info("Info Console"); | ||
Thread.Sleep(50); | ||
log.Fatal("Fatal Console"); | ||
log.Error("Hello Console"); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
log.Warn("Warn Console"); | ||
Thread.Sleep(500); | ||
log.Info("Info Console"); | ||
log.Fatal("Fatal Console"); | ||
log.Error("Hello Console"); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
log.Warn("Warn Console"); | ||
log.Info("Info Console"); | ||
Thread.Sleep(150); | ||
log.Fatal("Fatal Console"); | ||
log.Error("Hello Console"); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
log.Warn("Warn Console"); | ||
Thread.Sleep(450); | ||
log.Info("Info Console"); | ||
log.Fatal("Fatal Console"); | ||
log.Error("Hello Console"); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
log.Warn("Warn Console"); | ||
Thread.Sleep(250); | ||
log.Info("Info Console"); | ||
log.Fatal("Fatal Console"); | ||
log.Error("Hello Console"); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
log.Warn("Warn Console"); | ||
log.Info("Info Console"); | ||
Thread.Sleep(150); | ||
log.Fatal("Fatal Console"); | ||
log.Error("Hello Console"); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
log.Warn("Warn Console"); | ||
log.Info("Info Console"); | ||
Thread.Sleep(500); | ||
log.Fatal("Fatal Console"); | ||
log.Error("Hello Console"); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
log.Warn("Warn Console"); | ||
log.Info("Info Console"); | ||
log.Fatal("Fatal Console"); | ||
log.Error("Hello Console"); | ||
Thread.Sleep(250); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
log.Warn("Warn Console"); | ||
log.Info("Info Console"); | ||
log.Fatal("Fatal Console"); | ||
Thread.Sleep(150); | ||
log.Error("Hello Console"); | ||
log.Error("Error Console"); | ||
log.Debug("Debug Console"); | ||
Thread.Sleep(750); | ||
log.Warn("Warn Console"); | ||
log.Info("Info Console"); | ||
log.Fatal("Fatal Console"); | ||
Thread.Sleep(50); | ||
log.Error("Hello Console"); | ||
Console.WriteLine("Press any key to exit"); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Samples/Log4net.Appender.InfluxDBSyslog.Console/log4net.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<configSections> | ||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> | ||
</configSections> | ||
<log4net> | ||
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> | ||
</layout> | ||
</appender> | ||
<appender name="InfluxAppender" type="Log4net.Appender.InfluxDBSyslog.InfluxAppender, Log4net.Appender.InfluxDBSyslog"> | ||
<Scheme>http</Scheme> | ||
<Host>localhost</Host> | ||
<RemotePort>8086</RemotePort> | ||
<AppName>Console Test</AppName> | ||
<Facility>Console Test Custom Facility</Facility> | ||
</appender> | ||
<root> | ||
<level value="INFO" /> | ||
<appender-ref ref="ConsoleAppender" /> | ||
<appender-ref ref="InfluxAppender" /> | ||
</root> | ||
</log4net> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.