Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Log files timestamping

Discussion in 'Editor & General Support' started by svorobyov, Feb 7, 2020.

  1. svorobyov

    svorobyov

    Joined:
    Feb 6, 2020
    Posts:
    3
    Hi!

    Would it be possible to prepend timestamps to each editor's log line? (Or more generally set format to logging, e.g., as in syslog).

    It's needed for profiling and finding the most time-consuming operations. Otherwise, there's lots of unimportant "0.00...seconds" reports, but it's impossible to find the greediest.
     
    KislunA likes this.
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    Joe-Censored and MartinTilo like this.
  3. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    190
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    Thanks I passed this feedback on to the team. Something interesting that came up was if you define a UNITY_EXT_LOGGING environment variable, assign any value to it, the editor should now output timestamps with every line. I have not tested this myself but worth a try ;)
     
    TagRobertL and Joe-Censored like this.
  5. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    190
    Thanks for the quick response, Karl. Just so it was clear, I was referring to having timestamps inside of standalone player log files - not editor. For all of the bug reports that come in from our playerbase, we ask for logs. Without timestamps it makes it quite difficult to know when stuff happens.
     
    karl_jones and Joe-Censored like this.
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    It may be worth testing this env variable with players, I'm not sure if it's limited to editor only. If it works in player then you may be able to ask users to define it, depending on the platform.
    Alternatively use this and add the timestamps yourself. https://docs.unity3d.com/ScriptReference/Application.LogCallback.html
     
  7. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    190
    We have over 2 million players and it's too late to ask them to do it after they've already experienced the bug. To work, it'd need to be something that is turned on by us ahead of doing builds.
     
  8. TagRobertL

    TagRobertL

    Joined:
    Jun 17, 2021
    Posts:
    1
    Confirming this 'works' - a bit ugly, sample lines looks like this, bold is what is added, but solves a problem for us at least :)


    2022-04-26T08:59:29.580Z|0x7f43819a4300|System name: Linux
    2022-04-26T08:59:29.580Z|0x7f43819a4300|Distro version: #1 SMP Wed Mar 2 18:38:38 UTC 2022
     
    karl_jones likes this.
  9. mNKA

    mNKA

    Joined:
    Aug 19, 2021
    Posts:
    14
    So i need a script and place
    Environment.SetEnvironmentVariable("UNITY_EXT_LOGGING", "1");
    in Awake or Start?
    Am i missing something or do i understand something wrong, because that does not work for me.
    (Tried it with Unity 2020.3 on windows and linux)
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    No you would need to set the variable before the game starts.
     
  11. mNKA

    mNKA

    Joined:
    Aug 19, 2021
    Posts:
    14
    Oh, silly me. Thank you for the info.

    For everyone else who is searching for this:
    this works for the editor.log but not for the player.log, so it's not a solution for a build.
    The way to go would be the Application.LogCallback Karl Jones mentioned
     
  12. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,218
  13. mNKA

    mNKA

    Joined:
    Aug 19, 2021
    Posts:
    14
    that indeed sounds very intriguing and is apparently even added to 2020.3.37f1, do you know by any chance how this works? I can't find the setting for this or documentation
     
  14. NuclearCookieTF

    NuclearCookieTF

    Joined:
    Mar 29, 2021
    Posts:
    17
    Did anybody figure this out?
    The -timestamps argument seems promising but there's no documentation available.
     
    yutol2007 likes this.
  15. QAMightandDelight

    QAMightandDelight

    Joined:
    Mar 17, 2021
    Posts:
    6
    Adding
    -timestamps
    as a command line argument when starting the editor works like a charm, just tried that on our build system, will test it with the player (i.e. the game build itself):

    2022-11-29T17:39:41.308Z|0x3598|BuildPlayerGenerator: Succeeded2022-11-29T17:39:41.308Z|0x3598|
    2022-11-29T17:39:41.361Z|0x3598|Asset Pipeline Refresh: Total: 0.022 seconds - Initiated by RefreshV2(NoUpdateAssetOptions)
    2022-11-29T17:39:41.361Z|0x3598|[ScriptCompilation] Requested script compilation because: Recompiling scripts for player build.2022-11-29T17:39:41.361Z|0x3598|
    2022-11-29T17:39:41.361Z|0x3598|BuildPlayer: start building target 24


    @karl_jones there is two things I would like to request, if I may:
    - The ability to also enable showing the log level (Warning, Error, Exception etc) in the log line, analogue to how
    -timestamps
    does it for well timestamps. Especially for game servers, this is quite vital to have.
    - Could you see to it that
    -timestamps
    is added to the documentation? https://docs.unity3d.com/Manual/CommandLineArguments.html
     
    Last edited: Nov 29, 2022
  16. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    Thanks. Ill pass your feedback on.
     
    mgear likes this.
  17. lazylukey

    lazylukey

    Joined:
    May 26, 2017
    Posts:
    35
    Anyone had any luck getting this new CLI arg to work in a standalone player? Doesn't do anything for me on a standalone build built with 2020.3.43f1. It does work on the editor tho.
     
    fendercodes and NuclearCookieTF like this.
  18. lazylukey

    lazylukey

    Joined:
    May 26, 2017
    Posts:
    35
  19. CarePackage17

    CarePackage17

    Joined:
    Dec 6, 2014
    Posts:
    21
  20. holo-krzysztof

    holo-krzysztof

    Joined:
    Apr 5, 2017
    Posts:
    74
    Nope, only works in editor for some reason (Unity 2021.3.19).
    Neither setting the environment variable in a shell before starting a player build, nor the `-timestamps` argument are working for me. Might report another bug.
     
  21. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    The issue was converted into a feature request, the issue tracker only works for bugs.
    This was the response sent on the 15th March
     
    holo-krzysztof likes this.
  22. holo-krzysztof

    holo-krzysztof

    Joined:
    Apr 5, 2017
    Posts:
    74
    Thank you for posting the response here.

    I guess mentioning the functionality in the release notes as existing for player builds was a mistake then.
     
    karl_jones likes this.
  23. holo-krzysztof

    holo-krzysztof

    Joined:
    Apr 5, 2017
    Posts:
    74
  24. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    190
    Any updates on this? Timestamps in logs for standalone builds is one of the most important things to help us debug games in production.
     
    jackward84 likes this.
  25. jackward84

    jackward84

    Joined:
    Jan 26, 2017
    Posts:
    87
    +1 to please add timestamps. It's incredibly important to logging on remote servers. I shouldn't have to roll my own solution or use a 3rd party logging library to get such a basic function of logging.
     
    mNKA likes this.
  26. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    The inclusion of timestamps in the player log is being considered as a feature request. I have forwarded your comments to the relevant team. Thank you.
     
    fendercodes, mNKA and jackward84 like this.
  27. renchy91

    renchy91

    Joined:
    Nov 6, 2019
    Posts:
    2
    this is honestly embarrassing, end of 2023 and after all these years not to have this as a feature
     
  28. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    190
    Yeah, it's kind of mind boggling.