Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: anaselhajjaji/log4net.Appender.Loki
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: gabrielcerutti/log4net.Appender.Loki
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Nov 28, 2022

  1. Updated to use new Loki push api

    Added GZip compression
    Gabriel Cerutti committed Nov 28, 2022
    Copy the full SHA
    951a0df View commit details

Commits on Nov 30, 2022

  1. Update README.md

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    339a692 View commit details
  2. Copy the full SHA
    93acc7b View commit details
  3. Copy the full SHA
    5a3f37c View commit details
  4. Upgraded .Net Framework

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    f67d758 View commit details
  5. Update README.md

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    b574428 View commit details
  6. Copy the full SHA
    ece0edb View commit details
  7. Update README.md

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    e8eaa0c View commit details
  8. Copy the full SHA
    415135c View commit details
  9. Copy the full SHA
    be0bc06 View commit details
  10. Copy the full SHA
    ab52d39 View commit details
  11. Updated nuspec file

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    2f98ace View commit details
  12. Update README.md

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    b0089cd View commit details
  13. Updated root namespace

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    2a4bd3c View commit details
  14. Removed dependencies to Microsoft.Net and Microsoft.Bcl

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    93bc72e View commit details
  15. Update Log4Net.Appender.Grafana.Loki.nuspec

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    05f3bda View commit details
  16. Upgraded to Net Framework 4.8

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    50a3319 View commit details
  17. Update Log4Net.Appender.Grafana.Loki.nuspec

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    21ca19a View commit details
  18. Updated net framework version

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    63f7b6e View commit details
  19. Update Log4Net.Appender.Grafana.Loki.nuspec

    Gabriel Cerutti committed Nov 30, 2022
    Copy the full SHA
    c404ac8 View commit details

Commits on Dec 1, 2022

  1. Updated Example project

    Gabriel Cerutti committed Dec 1, 2022
    Copy the full SHA
    7bbaf59 View commit details
  2. Update README.md

    Gabriel Cerutti committed Dec 1, 2022
    Copy the full SHA
    86348cb View commit details
  3. Added loki icon

    Gabriel Cerutti committed Dec 1, 2022
    Copy the full SHA
    8283e5c View commit details
  4. Updated package version

    Gabriel Cerutti committed Dec 1, 2022
    Copy the full SHA
    91f422b View commit details
  5. Update Log4Net.Appender.Grafana.Loki.nuspec

    Gabriel Cerutti committed Dec 1, 2022
    Copy the full SHA
    44cac63 View commit details
  6. Update Log4Net.Appender.Grafana.Loki.nuspec

    Gabriel Cerutti committed Dec 1, 2022
    Copy the full SHA
    7342da3 View commit details

Commits on Dec 2, 2022

  1. Upgrade to netstandard 2.0

    Gabriel Cerutti committed Dec 2, 2022
    Copy the full SHA
    13dc5c8 View commit details
  2. Update Log4Net.Appender.Grafana.Loki.nuspec

    Gabriel Cerutti committed Dec 2, 2022
    Copy the full SHA
    f1f8ccf View commit details
  3. Update Log4Net.Appender.Grafana.Loki.csproj

    Gabriel Cerutti committed Dec 2, 2022
    Copy the full SHA
    949ccb2 View commit details
  4. Updated example project

    Gabriel Cerutti committed Dec 2, 2022
    Copy the full SHA
    773e29f View commit details
  5. Updated nuspec dependencies

    Gabriel Cerutti committed Dec 2, 2022
    Copy the full SHA
    d61e330 View commit details
  6. Update Log4Net.Appender.Grafana.Loki.nuspec

    Gabriel Cerutti committed Dec 2, 2022
    Copy the full SHA
    f6fa7c6 View commit details
12 changes: 6 additions & 6 deletions .github/workflows/netframework.build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dot Net Framework 4 (Build)
name: Dot Net Framework (Build)

on:
push:
@@ -12,15 +12,15 @@ jobs:
steps:
- name: Checkout the repository
uses: actions/checkout@master

- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.2
uses: NuGet/setup-nuget@v1.1.1

- name: Restore NuGet Packages
run: nuget restore log4net.Appender.Loki.sln

- name: Setup MSBuild Path
uses: warrenbuckley/Setup-MSBuild@v1
- name: Setup-msbuild
uses: microsoft/setup-msbuild@v1.1.3

- name: Build
run: msbuild log4net.Appender.Loki.csproj /p:Configuration=Release
run: msbuild Log4Net.Appender.Grafana.Loki.csproj /p:Configuration=Release
10 changes: 5 additions & 5 deletions .github/workflows/netframework.release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dot Net Framework 4 (Release)
name: Dot Net Framework (Release)

on:
push:
@@ -14,19 +14,19 @@ jobs:
uses: actions/checkout@master

- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.2
uses: NuGet/setup-nuget@v1.1.1

- name: Restore NuGet Packages
run: nuget restore log4net.Appender.Loki.sln

- name: Setup MSBuild Path
uses: warrenbuckley/Setup-MSBuild@v1
uses: microsoft/setup-msbuild@v1.1.3

- name: Build
run: msbuild log4net.Appender.Loki.csproj /p:Configuration=Release
run: msbuild Log4Net.Appender.Grafana.Loki.csproj /p:Configuration=Release

- name: Create NuGet Package
run: nuget pack log4net.Appender.Loki.csproj -OutputDirectory ./artifact -Prop Configuration=Release
run: nuget pack Log4Net.Appender.Grafana.Loki.csproj -OutputDirectory ./artifact -Prop Configuration=Release

- name: Upload Artifact
uses: actions/upload-artifact@v1.0.0
25 changes: 25 additions & 0 deletions Example.NetCore/Example.NetCore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Log4Net.Appender.Grafana.Loki.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions Example.NetCore/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// See https://aka.ms/new-console-template for more information

Console.WriteLine("Hello, World!");

var logger = log4net.LogManager.GetLogger("Program");

var fileInfo = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config");
if (fileInfo.Exists)
log4net.Config.XmlConfigurator.Configure(fileInfo);
else
throw new InvalidOperationException("No log config file found");

int count = 0;

while (true)
{
Thread.Sleep(2000);
logger.Debug($"Log number {count++}");
logger.Info($"Log number {count++}");
logger.Warn($"Log number {count++}");
logger.Error($"Log number {count++}");
logger.Fatal($"Log number {count++}");
}
34 changes: 34 additions & 0 deletions Example.NetCore/log4net.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="console" />
<appender-ref ref="file" />
<appender-ref ref="loki" />
</root>
<appender name="console" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %logger - %message%newline" />
</layout>
</appender>
<appender name="file" type="log4net.Appender.RollingFileAppender">
<file value="example.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger - %message%newline" />
</layout>
</appender>
<appender name="loki" type="Log4Net.Appender.Loki.LokiAppender, Log4Net.Appender.Grafana.Loki">
<Application value="Example" />
<Environment value="Development" />
<BufferSize value="10" />
<ServiceUrl value="" />
<BasicAuthUserName value="" />
<BasicAuthPassword value="" />
<GZipCompression value="true" />
<TrustSelfSignedCerts value="false" />
</appender>
</log4net>
18 changes: 12 additions & 6 deletions Example/Example.csproj
Original file line number Diff line number Diff line change
@@ -8,9 +8,10 @@
<OutputType>Exe</OutputType>
<RootNamespace>Example</RootNamespace>
<AssemblyName>Example</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -21,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -30,13 +32,16 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net40-full\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -48,15 +53,16 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\log4net.Appender.Loki.csproj">
<Project>{d2dd78d6-396a-4f1e-8d5e-0f7d4f8463eb}</Project>
<Name>log4net.Appender.Loki</Name>
<ProjectReference Include="..\Log4Net.Appender.Grafana.Loki.csproj">
<Project>{ecd5cca2-e1c6-4534-8236-c47261118867}</Project>
<Name>Log4Net.Appender.Grafana.Loki</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8 changes: 4 additions & 4 deletions Example/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace Example
@@ -13,7 +10,6 @@ class Program

static void Main(string[] args)
{
// or wherever your file is
var fileInfo = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config");
if (fileInfo.Exists)
log4net.Config.XmlConfigurator.Configure(fileInfo);
@@ -25,7 +21,11 @@ static void Main(string[] args)
while (true)
{
Thread.Sleep(2000);
logger.Debug($"Log number {count++}");
logger.Info($"Log number { count++ }");
logger.Warn($"Log number {count++}");
logger.Error($"Log number {count++}");
logger.Fatal($"Log number {count++}");
}
}
}
8 changes: 4 additions & 4 deletions app.config → Example/app.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.29.0" newVersion="2.2.29.0" />
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.2.29.0" newVersion="2.2.29.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup></configuration>
19 changes: 11 additions & 8 deletions Example/log4net.config
Original file line number Diff line number Diff line change
@@ -10,15 +10,8 @@
<conversionPattern value="%date %level %logger - %message%newline" />
</layout>
</appender>
<appender name="loki" type="log4net.Appender.LokiAppender, log4net.Appender.Loki">
<BufferSize value="3" />
<ServiceUrl value="https://localhost/loki" />
<BasicAuthUserName value="username" />
<BasicAuthPassword value="password" />
<TrustSelfCignedCerts value="false" />
</appender>
<appender name="file" type="log4net.Appender.RollingFileAppender">
<file value="myapp.log" />
<file value="example.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
@@ -28,4 +21,14 @@
<conversionPattern value="%date [%thread] %level %logger - %message%newline" />
</layout>
</appender>
<appender name="loki" type="Log4Net.Appender.Loki.LokiAppender, Log4Net.Appender.Grafana.Loki">
<Application value="Example" />
<Environment value="Development" />
<BufferSize value="10" />
<ServiceUrl value="" />
<BasicAuthUserName value="" />
<BasicAuthPassword value="" />
<GZipCompression value="true" />
<TrustSelfSignedCerts value="false" />
</appender>
</log4net>
2 changes: 1 addition & 1 deletion Example/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.8" targetFramework="net40" />
<package id="log4net" version="2.0.15" targetFramework="net462" />
</packages>
Binary file added Image/loki.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions Log4Net.Appender.Grafana.Loki.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Example.NetCore\**" />
<Compile Remove="Example\**" />
<Compile Remove="packages\**" />
<EmbeddedResource Remove="Example.NetCore\**" />
<EmbeddedResource Remove="Example\**" />
<EmbeddedResource Remove="packages\**" />
<None Remove="Example.NetCore\**" />
<None Remove="Example\**" />
<None Remove="packages\**" />
</ItemGroup>

<ItemGroup>
<None Remove="LICENSE" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions Log4Net.Appender.Grafana.Loki.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>$id$</id>
<version>1.0.5</version>
<title>$title$</title>
<icon>loki.png</icon>
<authors>Gabriel Cerutti</authors>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0</license>
<projectUrl>https://github.com/gabrielcerutti/log4net.Appender.Loki</projectUrl>
<description>Log4Net buffering appender to send log messages to Grafana Loki directly using latest Loki HTTP API (POST /loki/api/v1/push), JSON format and GZip compression.</description>
<!--releaseNotes>Summary of changes made in this release of the package.</releaseNotes-->
<copyright>Copyright 2022</copyright>
<tags>log4net appender grafana loki</tags>
<dependencies>
<dependency id="log4net" version="2.0.15" />
<dependency id="Newtonsoft.Json" version="13.0.2" />
</dependencies>
</metadata>
<files>
<file src="Image\loki.png" target="" />
<file src="README.md" target="docs\" />
</files>
</package>
28 changes: 28 additions & 0 deletions Loki/Labels.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Log4Net.Appender.Loki
{
public class LokiLabel
{
public LokiLabel(string key, string value)
{
Key = key;
Value = value;
}

public string Key { get; }

public string Value { get; }
}

public class LokiProperty
{
public LokiProperty(string key, string value)
{
Key = key;
Value = value;
}

public string Key { get; }

public string Value { get; }
}
}
20 changes: 0 additions & 20 deletions Loki/Labels/LokiLabel.cs

This file was deleted.

Loading