NLog: ${callsite} in cross domain application sometime not working (Akka.net)
Hi.
Type: Bug
NLog version: (> 4.3.7) builded from commit cdb1fcf14f6e505317ab9cdd00322fe60ba4b4ca
Platform: .Net 4.6.1
Current NLog config
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- go to http://nlog-project.org/wiki/Configuration_file for more information -->
<variable name="ConsoleLayout" value="${date:format=HH\:mm\:ss.fff} ${pad:padding=5:inner=${level:uppercase=true}} ${message} ${onexception:EXCEPTION OCCURRED\:${exception:format=tostring}}" />
<variable name="NormalLayout" value="${longdate} ${level:uppercase=true} ${callsite} ${message} ${onexception:EXCEPTION OCCURRED\:${exception:format=tostring}}" />
<variable name="VerboseLayout" value="${longdate} ${level:upperCase=true} ${callsite:includSourcePath=true} ${message} ${exception:format=tostring}" />
<variable name="ExceptionVerboseLayout" value="${VerboseLayout} (${stacktrace:topFrames=10})
${exception:format=ToString}" />
<targets async="true">
<target xsi:type="File" name="appLog"
layout="${VerboseLayout}"
fileName="${basedir}/logs/current_log.txt"
archiveFileName="${basedir}/archives/log.{#}.zip"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="7"
enableArchiveFileCompression="true" />
<target name="errorsLog"
xsi:type="FilteringWrapper"
condition="length('${exception}')>0">
<target xsi:type="File" name="warnLog"
layout="${ExceptionVerboseLayout}"
fileName="${basedir}/logs/errors.txt"
archiveFileName="${basedir}/archives/errors.{#}.zip"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="15"
enableArchiveFileCompression="true" />
</target>
<target xsi:type="ColoredConsole" name="console" layout="${ConsoleLayout}">
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="White" backgroundColor="Red" />
<highlight-word text="DEBUG" foregroundColor="DarkBlue" />
<highlight-word text="INFO" foregroundColor="DarkGreen" />
<highlight-word text="WARN" foregroundColor="Black" backgroundColor="Yellow" />
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="appLog,console" />
<logger name="*" minlevel="Warn" writeTo="errorsLog,warnLog" />
</rules>
</nlog>
In case of a BUG:
- What is the current result? Incorrect ${callsite} in Log
- What is the expected result? ${callsite} in my class
- Did you checked the Internal log? Nope
- Please post full exception details (message, stacktrace, inner exceptions)
${callsite} in cross domain application sometime not working (using with Akka.net). I use NLog in my Adapter class. Log object shared across 2 AppDomains. It’s fine works, but if I use this object in Akka.net actor I get incorrect ${callsite}. Maybe Akka.net issue.
public class NLogAdapter : MarshalByRefObject, ILog {
// cropped. ^^^ this object used by 2 AppDomains + used by Akka.net Logging
public NLogAdapter()
{
LogManager.AddHiddenAssembly(Assembly.GetExecutingAssembly());
LogManager.AddHiddenAssembly(Assembly.GetAssembly(typeof(NLog.Logger)));
_nlog = LogManager.GetCurrentClassLogger();
}
}
What get in log (error log with stacktrace):
2016-10-04 11:00:11.2872 ERROR NLog.LoggerImpl.Write [akka://RuleProcessor/user/AggregateRuleGroupActor#388440039] Test! (CrossContextChannel.SyncProcessMessage => Thread.InternalCrossContextCallback => CrossContextChannel.SyncProcessMessageCallback => ServerContextTerminatorSink.SyncProcessMessage => ServerObjectTerminatorSink.SyncProcessMessage => StackBuilderSink.SyncProcessMessage => StackBuilderSink._PrivateProcessMessage => NLogAdapter.Error => Logger.Error => LoggerImpl.Write)
- Are there any work arrounds? yes/no no
- Is there a version in which it did worked? I don’t know
- Can you help us by writing an unit test? maybe if can reproduce without Akka.net
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 21 (11 by maintainers)
Yes,
I tried you find a fix, but I failed.
There is an option to set the stacktrace to NLog (
LogEventInfo.SetStackTrace
)But could not find the stacktrace captured by Akka.net