NLog 不会通过混淆发出消息
我有一个试图混淆的应用程序。未混淆时,程序会发出 NLog 日志消息,但混淆后,即使应用程序的其余部分按预期运行,它也根本不会生成任何消息。我已经尝试了几种混淆器,它们都有相同的症状。有没有人有什么可以看的地方的建议。我生成了 NLog 内部日志记录工具,它们看起来相同。我的配置非常简单:
// enable internal logging to the console
InternalLogger.LogToConsole = true;
// enable internal logging to a file
InternalLogger.LogFile = "log.txt";
// set internal log level
InternalLogger.LogLevel = LogLevel.Trace;
LogTarget = new MemoryTarget();
LogTarget.Layout = "${message}";
NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(LogTarget, LogLevel.Trace);
I have an application that I'm trying to obfuscate. When unobfuscated, the program emits NLog logging messages, but after obfuscation, it doesn't generate any messages at all even though the rest of the application operates as expected. I've tried several obfuscators and they have the same symptoms. Does anyone have any suggestions of places to look. I generated the NLog internal logging facilities and they appear identical. My configuration is quite simple:
// enable internal logging to the console
InternalLogger.LogToConsole = true;
// enable internal logging to a file
InternalLogger.LogFile = "log.txt";
// set internal log level
InternalLogger.LogLevel = LogLevel.Trace;
LogTarget = new MemoryTarget();
LogTarget.Layout = "${message}";
NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(LogTarget, LogLevel.Trace);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最有可能的是,NLog 以某种方式使用反射,导致混淆的程序集无法记录。
您是否也混淆了 NLog 程序集,或者只是混淆了您自己的程序集?
尝试在混淆工具中打开“符号重命名”,看看是否有影响。如果它有效,那么您就知道原因,并且可以深入了解以排除重命名相关类/成员。
Most probably, NLog is using Reflection in some way which is causing the obfuscated assembly to fail to log.
Are you obfuscating the NLog assembly as well or just your own assembly?
Try turning of "Symbol Renaming" in your obfuscation tool to see if it makes a difference. If it works, then you know the cause and you can drill down to exclude from renaming the relevant classes/members.