Question

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);
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top