Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Unity.Logging.Log generated by 'LoggingSourceGenerator' conflicts with Unity.Logging package

Discussion in 'Unity Transport' started by Selmar, Jun 24, 2023.

  1. Selmar

    Selmar

    Joined:
    Sep 13, 2011
    Posts:
    57
    upload_2023-6-24_13-46-52.png

    To clarify, the conflict is in the IDE (Visual Studio) only, there is no actual compiler error inside the editor.

    It messes up intellisense, auto completion, cleaning up unused using directives, and more. Compiling inside visual studio does not work (the compiler fails), so debugging is not possible either.

    Edit: I posted this in the wrong forum, this should be in the Unity Transport forum.. Sorry.
     
    Last edited: Jun 24, 2023
  2. Selmar

    Selmar

    Joined:
    Sep 13, 2011
    Posts:
    57
    Then again, of course, maybe it is me..

    https://docs.unity3d.com/Packages/com.unity.logging@1.0/manual/getting-started.html

    The docs mention to create a separate assembly. Is this mandatory, perhaps? I'm not sure how it solves the issue, though, since I'd like to use netcode and logging in the same assembly, but maybe I'm missing something.

    I'd be interested to know why it works like this if that's the case (curiosity!).
     
  3. Selmar

    Selmar

    Joined:
    Sep 13, 2011
    Posts:
    57
    I had to upgrade Unity Transport to 2.0.0-pre.8.

    All good.
     
  4. Selmar

    Selmar

    Joined:
    Sep 13, 2011
    Posts:
    57
    This doesn't seem to be working entirely.

    When I try to use
    Unity.Logging.Log.To(m_logger)
    , the problem comes back. It works fine with Info, Warning, etc.
     
  5. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    416
    What version of Visual Studio are you using?

    You also mention using Netcode. Do you mean Netcode for Entities? If so, do you get the same problem if using the NetDebug singleton? Or do you have a specific requirement to use custom loggers?
     
  6. Selmar

    Selmar

    Joined:
    Sep 13, 2011
    Posts:
    57
    NetCode for GameObjects, VS 17.5.1.

    I found this issue when I tried to use dependency injection instead of using statics. I was using this to forward the logs for server builds (as in here), because the NGO docs say
    It looks like maybe it's not strictly speaking necessary: I've seen some logs in the file that were logged before I even set up the custom logger, so this warrants some experimentation on my side. In any case, I'm not blocked on this.
     
  7. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    416
    Yeah, using the logging package is certainly not required for a server-hosted game. It provides some functionality that's typically useful for servers (log rotation, asynchronous logging), but you'll get basic log files with Unity's default logger too and if that's sufficient for your use case, I'd recommend sticking with that. I'll reach out to the documentation team to make this clearer in the documentation.

    I'll also have a look at that issue with Visual Studio. It does look very annoying.
     
    Selmar likes this.