Skip to content

Commit

Permalink
Merge pull request #92 from AkkaNetContrib/dev
Browse files Browse the repository at this point in the history
Akka.Logger.NLog v1.4.10 Release
  • Loading branch information
Aaronontheweb authored Oct 29, 2020
2 parents 9be586c + 093eb70 commit 9fc9d31
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#### 1.4.10 October 29 2020 ####
- Update Akka to 1.4.10
- Update NLog to 4.7.5
- Resolve [Null reference exception due to RemoteActorRefProvider.RemoteInternals being null](https://github.com/akkadotnet/akka.net/issues/4579)


#### 1.4.5 May 4 2020 ####

- Update Akka to 1.4.5
Expand Down
2 changes: 1 addition & 1 deletion src/Akka.Logger.NLog.Tests/Akka.Logger.NLog.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="Akka.TestKit.Xunit2" Version="1.4.5" />
<PackageReference Include="Akka.TestKit.Xunit2" Version="1.4.10" />
</ItemGroup>

<ItemGroup>
Expand Down
30 changes: 27 additions & 3 deletions src/Akka.Logger.NLog.Tests/NLogFormattingSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public class NLogFormattingSpecs : TestKit.Xunit2.TestKit
private static readonly Config Config = @"akka.loglevel = DEBUG";

private readonly ILoggingAdapter _loggingAdapter;
const string ActorSystemName = "my-test-system";
const string LogSourceName = "my-test-system";

public NLogFormattingSpecs(ITestOutputHelper helper) : base(Config, output: helper)
{
Config myConfig = @"akka.loglevel = DEBUG
akka.loggers=[""Akka.Logger.NLog.NLogLogger, Akka.Logger.NLog""]";

var system = ActorSystem.Create(ActorSystemName, myConfig);
var system = ActorSystem.Create(LogSourceName, myConfig);

_loggingAdapter = Logging.GetLogger(system.EventStream, system.Name);

Expand Down Expand Up @@ -75,11 +75,35 @@ public void LoggingTestWithEventProperties(LogLevel level, string formatStr, obj
Thread.Sleep(10);
}

var formattedResultString = string.Format(resultStr, ActorSystemName,
var formattedResultString = string.Format(resultStr, LogSourceName,
Thread.CurrentThread.ManagedThreadId.ToString().PadLeft(4, '0'));

Assert.NotEmpty(loggingTarget.Logs);
Assert.Equal(formattedResultString, loggingTarget.Logs.Last());
}

[Theory]
[InlineData(LogLevel.InfoLevel, "test {color} case", new object[] { "Red" }, "test {{color}} case|color=Red, logSource={0}, actorPath={1}, threadId={2}")]
public void LoggingWithStructuredLogging(LogLevel level, string formatStr, object[] formatArgs, string resultStr)
{
var loggingTarget = new global::NLog.Targets.MemoryTarget { Layout = "${message:raw=true}|${all-event-properties}" };
global::NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(loggingTarget);

loggingTarget.Logs.Clear();
_loggingAdapter.Log(level, formatStr, formatArgs);

for (var i = 0; i < 100; ++i)
{
if (loggingTarget.Logs.Count != 0)
break;

Thread.Sleep(10);
}

var formattedResultString = string.Format(resultStr, LogSourceName, TestActor.Path.ToString(), Thread.CurrentThread.ManagedThreadId.ToString());

Assert.NotEmpty(loggingTarget.Logs);
Assert.Equal(formattedResultString, loggingTarget.Logs.Last());
}
}
}
4 changes: 2 additions & 2 deletions src/Akka.Logger.NLog/Akka.Logger.NLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Akka" Version="1.4.5" />
<PackageReference Include="NLog" Version="4.7.0" />
<PackageReference Include="Akka" Version="1.4.10" />
<PackageReference Include="NLog" Version="4.7.5" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Akka.Logger.NLog/NLogLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Akka.Logger.NLog
/// </summary>
public class NLogLogger : ReceiveActor, IRequiresMessageQueue<ILoggerMessageQueueSemantics>
{
private readonly ILoggingAdapter _log = Context.GetLogger();
private readonly ILoggingAdapter _log = Logging.GetLogger(Context.System.EventStream, "NLogLogger");

private static void Log(LogEvent logEvent, Action<NLogger, LogEvent> logStatement)
{
Expand Down

0 comments on commit 9fc9d31

Please sign in to comment.