Logger configuration

I come from the java world where you usually have very fine grained control over your logging. You can specify for each class/namespace at which level messages are logged and you can also change the log level at application run time.

It seems that the unity built-in logging system has not that much control into it. You can disable debug logging for release builds but that seems to be it. What I ideally would like to do is enable debug logging specifically for certain classes at runtime without having to go back into the code and comment out/in log statements. Is something like this possible with Unity’s built-in logger? If not, are there libraries available that solve this problem and integrate with Unity?

Unity does not provide near the flexibility you desire and I personally found this limiting as well. Certain components like NetworkManager can control logLevel, but for a generic solution you would need to create a log wrapper. Just to be complete for others, here is a link to disable Unity logging for release builds.

Fortunately the Unity logging limitation lead me to create NLog asset store product, and your requests could literally be the summary of this asset. NLog provides log level filtering based upon namespace/class, ability to compile out logger per platform, various logging targets (UnityConsole/GameConsole/RemoveViewer/File/Email), and endless log message formatting/content options just for starters.

I’ve found that Debug.Log has a surprisingly high performance impact for such a simple task, especially when in the editor. Two or three log messages per update brought my game’s performance to a crawl, and I was surprised when I found the culprit. For that reason alone I’d use an alternative logging system if you plan to use a good number of log messages during development testing. I wrote my own for the current game I’m making (doesn’t have some of the features you want though).