Skip to content

Commit

Permalink
change version and add description
Browse files Browse the repository at this point in the history
  • Loading branch information
moberacker committed Oct 10, 2018
1 parent 9f16ef6 commit 7284bd5
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 66 deletions.
4 changes: 2 additions & 2 deletions Log4ALA/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.3")]
[assembly: AssemblyFileVersion("2.3.3")]
[assembly: AssemblyVersion("2.3.4")]
[assembly: AssemblyFileVersion("2.3.4")]
5 changes: 4 additions & 1 deletion Log4ALATest.Core/Log4ALATest.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@


<ItemGroup>
<PackageReference Include="Log4ALA" Version="2.3.3" />
<PackageReference Include="Log4ALA" Version="2.3.4" />
</ItemGroup>






<ItemGroup>
<None Update="appsettings.buildsys.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
6 changes: 3 additions & 3 deletions Log4ALATest.Core/LoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ static void Main(string[] args)
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));


////Log messages with semicolon separated key=value strings...the keys will then be mapped to Azure Log Analytic properties/columns.
////Log messages with [;] separated key[=]value strings...the keys will then be mapped to Azure Log Analytic properties/columns.
for (int i = 0; i < 3; i++)
{
alaLogger2.Info($"id=log-{i}; message=netstandard2-test-{i}");
alaLogger2.Info($" message[=]netstandard2-test-{i}[;] id[=]log{i}[;] intTest[=]{i}[;] doubleTest[=]{i}={5}");
}


System.Console.WriteLine("done");



System.Threading.Thread.Sleep(new TimeSpan(1, 5, 0));


}
}
}
31 changes: 16 additions & 15 deletions Log4ALATest.Core/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@
"jsonDetection": "true",
"batchSizeInBytes": "30000",
"batchWaitMaxInSec": "60",
"coreFieldNames": "{'DateFieldName':'DateValue','MiscMessageFieldName':'MiscMsg','LoggerFieldName':'Logger','LevelFieldName':'Level'}"
"coreFieldNames": "{'DateFieldName':'DateValue','MiscMessageFieldName':'MiscMsg','LoggerFieldName':'Logger','LevelFieldName':'Level'}",
"keyValueSeparator": "[=]",
"keyValuePairSeparator": "[;]"
},
"alaQueueSizeLogIntervalEnabled": "false",
"alaQueueSizeLogIntervalInSec": "100",

"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
"alaQueueSizeLogIntervalEnabled": "false",
"alaQueueSizeLogIntervalInSec": "100",
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
}
}
4 changes: 2 additions & 2 deletions Log4ALATest/Log4ALATest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Log4ALA, Version=2.3.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Log4ALA.2.3.3\lib\net45\Log4ALA.dll</HintPath>
<Reference Include="Log4ALA, Version=2.3.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Log4ALA.2.3.4\lib\net45\Log4ALA.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.5\lib\net45-full\log4net.dll</HintPath>
Expand Down
54 changes: 25 additions & 29 deletions Log4ALATest/LoggerTests.cs
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
using log4net;
using System;
using log4net.Config;
using System.IO;
using log4net.Repository;
using System.Reflection;

namespace Log4ALATest
namespace Log4ALATest.Core
{

class LoggerTests
{
private static ILoggerRepository REPOSITORY = log4net.LogManager.CreateRepository(Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy));

private static ILog alaLogger1 = LogManager.GetLogger("Log4ALALogger_1");
private static ILog alaLogger2 = LogManager.GetLogger("Log4ALALogger_2");
private static ILog alaLogger3 = LogManager.GetLogger("Log4ALALogger_3");
private static ILog alaLogger2 = LogManager.GetLogger(REPOSITORY.Name, "Log4ALALogger_2");

static void Main(string[] args)
{

//Log message as anonymous type... the properties will then be mapped to Azure Log Analytic properties/columns.
for (int i = 0; i < 10; i++)
{
alaLogger1.Info(new { id = $"log-{i}", message = $"test-{i}" });
}
var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));

System.Console.WriteLine("done1");

//Log messages with semicolon separated key=value strings...the keys will then be mapped to Azure Log Analytic properties/columns.
for (int i = 0; i < 10; i++)
////Log messages with semicolon separated key=value strings...the keys will then be mapped to Azure Log Analytic properties/columns.
for (int i = 0; i < 100; i++)
{
alaLogger2.Info($"id=log-{i}; message=test-{i}");
alaLogger2.Info($"id=log-{i}; message=netstandard2-test-{i}; intTest={i}; doubleTest={i}.{5}");
}

System.Console.WriteLine("done2");

//Log messages with semicolon separated key=value strings and duplicate key detection... the duplicate keys in the following example
//will be mapped to Azur Log Analytic properties/columns message_Duplicate0 and message_Duplicate1.
for (int i = 0; i < 10; i++)
{
alaLogger2.Info($"id=log-{i}; message=test-{i}; message=test-{i}; message=test-{i}");
}
System.Console.WriteLine("done");

System.Console.WriteLine("done3");

//Log message as json string ...the json properties will then be mapped to Azure Log Analytic properties/columns.
for (int i = 0; i < 10; i++)
{
alaLogger3.Info($"{{\"id\":\"log-{i}\", \"message\":\"test-{i}\"}}");
}

System.Console.WriteLine("done4");
System.Threading.Thread.Sleep(new TimeSpan(0, 0, 20));


//System.Console.WriteLine("shutdown logger...");

//LogManager.Shutdown();
//System.Console.WriteLine("shutdown succeeded...");

System.Threading.Thread.Sleep(new TimeSpan(1, 0, 0));


System.Threading.Thread.Sleep(new TimeSpan(0, 5, 0));
}
}
}
}
2 changes: 1 addition & 1 deletion Log4ALATest/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Log4ALA" version="2.3.3" targetFramework="net452" />
<package id="Log4ALA" version="2.3.4" targetFramework="net452" />
<package id="log4net" version="2.0.5" targetFramework="net452" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.1.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
Expand Down
4 changes: 2 additions & 2 deletions NuGet/Log4ALA.Core/Log4ALA.core.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<metadata minClientVersion="3.3.0">
<id>Log4ALA.Core</id>
<title>Log4ALA</title>
<version>2.3.3</version>
<version>2.3.4</version>
<authors>mob</authors>
<owners>mob</owners>
<projectUrl>https://ptv-logistics.github.io/Log4ALA/</projectUrl>
<licenseUrl>https://github.com/ptv-logistics/Log4ALA/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Log4Net appender for Azure Log Analytics (ALA)... sending data to Azure Log Analytics with the HTTP Data Collector API. The data will also be logged/sent asynchronously for high performance and to avoid blocking the caller thread.</description>
<copyright>Copyright © 2018 PTV Group</copyright>
<releaseNotes>Added .net standard2.0 support</releaseNotes>
<releaseNotes>Optimize json detection (now the detection will only be done if the log message really contains a json string to increase the performance by avoiding unnecessary exception flooding during the json check) and add new properties keyValueSeparator and keyValuePairSeparator to configure any other single char or multiple chars as separator for the keyValue detection in the log message (https://github.com/ptv-logistics/Log4ALA#features under bullet point 9). </releaseNotes>
<dependencies>
<group targetFramework=".netstandard2.0">
<dependency id="log4net" version="2.0.8" />
Expand Down
6 changes: 2 additions & 4 deletions NuGet/Log4ALA/Log4ALA.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
<metadata minClientVersion="3.3.0">
<id>Log4ALA</id>
<title>Log4ALA</title>
<version>2.3.3</version>
<version>2.3.4</version>
<authors>mob</authors>
<owners>mob</owners>
<projectUrl>https://ptv-logistics.github.io/Log4ALA/</projectUrl>
<licenseUrl>https://github.com/ptv-logistics/Log4ALA/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Log4Net appender for Azure Log Analytics (ALA)... sending data to Azure Log Analytics with the HTTP Data Collector API. The data will also be logged/sent asynchronously for high performance and to avoid blocking the caller thread.</description>
<copyright>Copyright © 2018 PTV Group</copyright>
<releaseNotes>
Add new property enableDebugConsoleLog to enable a kind of verbose/debug logging on console and in the log4ALA_error.log.
</releaseNotes>
<releaseNotes>Optimize json detection (now the detection will only be done if the log message really contains a json string to increase the performance by avoiding unnecessary exception flooding during the json check) and add new properties keyValueSeparator and keyValuePairSeparator to configure any other single char or multiple chars as separator for the keyValue detection in the log message (https://github.com/ptv-logistics/Log4ALA#features under bullet point 9). </releaseNotes>
<dependencies>
<group targetFramework="net45">
<dependency id="log4net" version="2.0.5" />
Expand Down
2 changes: 1 addition & 1 deletion NuGet/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ REM %MSBUILD% build.proj /target:NuGetRestore
REM %MSBUILD% /p:Configuration=Release ..\Log4ALA.sln
REM %MSBUILD% build.proj /target:NuGetPack /property:Configuration=Release;RELEASE=true
REM PackageVersion=4.5.0;PatchVersion=0;PatchCoreVersion=0
%MSBUILD% build.proj /target:BuildAll /property:Configuration=Release;RELEASE=true;MajorVersion=2;MinorVersion=3;PatchVersion=3
%MSBUILD% build.proj /target:BuildAll /property:Configuration=Release;RELEASE=true;MajorVersion=2;MinorVersion=3;PatchVersion=4
pause
2 changes: 1 addition & 1 deletion NuGet/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<MajorVersion Condition="$(MajorVersion) == ''">2</MajorVersion>
<MinorVersion Condition="$(MinorVersion) == ''">3</MinorVersion>
<PatchVersion Condition="$(PatchVersion) == ''">3</PatchVersion>
<PatchVersion Condition="$(PatchVersion) == ''">4</PatchVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,24 @@ namespace Log4ALATest
//Log message as json string ...the json properties will then be mapped to Azure Log Analytic properties/columns.
for (int i = 0; i < 10; i++)
{
alaLogger3.Info($"{{\"id\":\"log-{{i}}\", \"message\":\"test-{{i}}\"}}");
alaLogger3.Info($"{\"id\":\"log-{i}\", \"message\":\"test-{i}\"}");
}
System.Console.WriteLine("done4");


//log message if separators are changed from defaults = and ; to [=] and [;]
//Log4ALAAppender_3.keyValueSeparator="[=]"
//and
//Log4ALAAppender_3.keyValuePairSeparator="[;]"
for (int i = 0; i < 10; i++)
{
alaLogger3.Info($"id[=]log={i}[;]message[=]test={i}");
}


System.Console.WriteLine("done5");

System.Threading.Thread.Sleep(new TimeSpan(0, 5, 0));
}
}
Expand Down Expand Up @@ -111,12 +124,21 @@ System.Net.WebRequest.DefaultWebProxy = new System.Net.WebProxy("http://IP:PORT/
1. You can batch multiple log messages together in a single request by configuration with the properties batchSizeInBytes, batchNumItems or batchWaitInSec (described further down).
If batchSizeInBytes will be choosed the collecting of the log data will be stopped and send to Azure Log Analyitcs if batchSizeInBytes will be reached or the duration is >= BatchWaitMaxInSec with default 60s or
batch size >= BatchSizeMax 30 mb this conditions applies also if you choose batchNumItems. In case of batchWaitInSec collecting will be stopped and send if batchWaitInSec will be reached or the batch size will be >= BatchSizeMax 30 mb.
2. Auto detection/convertion of numeric, boolean, and dateTime string values to the Azure Log Analytics type _d, _b and _t.
2. Auto detection/convertion of numeric, boolean, and dateTime string values to the [ Azure Log Analytics type _s, _g, _d, _b and _t](https://docs.microsoft.com/en-us/azure/log-analytics/log-analytics-data-collector-api#record-type-and-properties)().
3. Field values greater than 32 KB will be truncated (the value could be configured with maxFieldByteLength).
4. Field names greater than 500 chars will be truncated (the value could be configured with maxFieldNameLength).
5. Configurable core field names (the value could be configured with coreFieldNames)
6. Configurable background worker thread priority (the value could be configured with threadPriority)
5. Configurable core field names (the value could be configured with coreFieldNames).
6. Configurable background worker thread priority (the value could be configured with threadPriority).
7. Configurable abortTimeoutSeconds - the time to wait for flushing the remaining buffered data to Azure Log Analytics if e.g. the Log4Net process will be shutdown.
8. Configurable detection of json strings (e.g. "{\"id\":\"log-1\", \"message\":\"test-1\"}") or key value (e.g. "") in the log messages with the properties jsonDetection (default true) and keyValueDetection (default true). Azure Log Analytics creates
custom fields/ record types for each incoming json property or key name.
9. Configurable keyValue detection with keyValueSeparator and keyValuePairSeparator properties. To configure any other single char or multiple chars as separator for the keyValue detection in the log message.
To avoid format conflicts e.g. with the semicolon separated key=value log message "Err=throws xy exception;Id=123" normally you will get two custom fields/records in Azure Log Analytics
Err_s:"throws xy exception" and Id_d:123 but if you like to use one of the default keyValueSeparator "=" or the default keyValuePairSeparator ";" chars in the value itself e.g. "Err=throws exception = exception
name;Id=123" you will run into a format conflict normally you expect to get Err_s:"throws exception = exception name" but for the Err key in the log message you will get Err_s:"throws" and MiscMsg_s:"exception
exception name" and Id_d:123 as custom fields in Azure Log Analytics because of the keyValue separator char "=" contained in the value itself. To avoid this behaviour e.g. set the properties keyValueSeparator
to "[=]" and keyValuePairSeparator to "[;]" and now your log message should look like "Err[=]throws exception = exception name[;]Id[=]123".



## General Configuration
Expand Down Expand Up @@ -158,6 +180,12 @@ This configuration is also available as a [App.config](https://github.com/ptv-lo
<add key="Log4ALAAppender_2.logType" value=""/>
<add key="Log4ALAAppender_2.logMessageToFile" value="true"/>

<!-- optional log message key value separator e.g. "key=value" (default =) -->
<add key="Log4ALAAppender_3.keyValueSeparator" value="[=]"/>
<!-- optional log message key value pair separator e.g "key1=value1;key2=value2" (default ;) -->
<add key="Log4ALAAppender_3.keyValuePairSeparator" value="[;]"/>


<!--Log4ALA common settings-->
<add key="alaQueueSizeLogIntervalEnabled" value="false"/>
<add key="alaQueueSizeLogIntervalInSec" value="100"/>
Expand Down Expand Up @@ -191,7 +219,9 @@ This configuration is also available as a [appsettings.json](https://github.com/
"logMessageToFile": true,
"jsonDetection": true,
"batchWaitMaxInSec": "2",
"coreFieldNames": "{'DateFieldName':'DateValue','MiscMessageFieldName':'MiscMsg','LoggerFieldName':'Logger','LevelFieldName':'Level'}"
"coreFieldNames": "{'DateFieldName':'DateValue','MiscMessageFieldName':'MiscMsg','LoggerFieldName':'Logger','LevelFieldName':'Level'}",
"keyValueSeparator": "[=]",
"keyValuePairSeparator": "[;]"
},
"alaQueueSizeLogIntervalEnabled": false,
"alaQueueSizeLogIntervalInSec": "100",
Expand Down Expand Up @@ -342,6 +372,14 @@ Control Panel > System > Advanced system settings > Environment Variables... > N
<abortTimeoutSeconds value="10"/>
-->

<!-- optional log message key value separator e.g. "key=value" (default =)
<keyValueSeparator value="[=]"/>
-->

<!-- optional log message key value pair separator e.g "key1=value1;key2=value2" (default ;)
<keyValuePairSeparator value="[;]"/>
-->

</appender>

<!--
Expand Down

0 comments on commit 7284bd5

Please sign in to comment.