none
vstest.console.exe ignores logging from .Net Core ILoggerFactory RRS feed

  • Question

  • I'm setting up a CI job to run a bunch of xunit tests, and I'm running into a problem getting the .Net Core logging to show up when using vstest.console.exe.

    If I run the tests using the following:
    `"C:\Program Files\dotnet\dotnet.exe" test SomeProject.csproj --configuration release --no-build --logger trx;LogFileName=TestResults.xml`

    Then everything I log using the .Net Core ILoggerFactory infrastructure shows up on the console.  You can see the "info: Startup [0]" on the last line of the output here:
    ````

    2017-05-16T14:03:56.0426109Z Test run for C:\VSTS\Agent\_work\3\s\tests\SomeProject\bin\release\net46\SomeProject.dll(.NETFramework,Version=v4.6)
    2017-05-16T14:03:56.1051160Z Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
    2017-05-16T14:03:56.1051160Z Copyright (c) Microsoft Corporation.  All rights reserved.
    2017-05-16T14:03:56.1051160Z 
    2017-05-16T14:03:56.2301258Z Starting test execution, please wait...
    2017-05-16T14:03:59.5713888Z [xUnit.net 00:00:01.0793776]   Discovering: SomeProject
    2017-05-16T14:03:59.7432771Z [xUnit.net 00:00:01.2763091]   Discovered:  SomeProject
    2017-05-16T14:04:00.6190432Z [xUnit.net 00:00:02.1622299]   Starting:    SomeProject
    2017-05-16T14:04:06.9597949Z info: Startup[0]
    2017-05-16T14:04:06.9597949Z       Configure begin.


    ````

    However, if I run the tests using the following:
    `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" C:\VSTS\Agent\_work\3\s\tests\SomeProject\bin\release\net46\SomeProject.dll  /Settings:C:\VSTS\Agent\_work\_temp\0740c520-3a41-11e7-afeb-6988f1be9642.runsettings /EnableCodeCoverage /logger:trx"`

    Then the same logging doesn't appear on the console anymore.  (i.e. "info: Startup[0]")

    The console looks like this, instead:
    2017-05-16T14:07:43.3943281Z Microsoft (R) Test Execution Command Line Tool Version 15.0.26228.0
    2017-05-16T14:07:43.3943281Z Copyright (c) Microsoft Corporation. All rights reserved.
    2017-05-16T14:07:43.3943281Z
    2017-05-16T14:07:43.5661808Z Starting test execution, please wait...
    2017-05-16T14:08:05.9438992Z Information: [xUnit.net 00:00:03.6824986] Discovering: SomeProject
    2017-05-16T14:08:05.9438992Z
    2017-05-16T14:08:06.5841837Z Information: [xUnit.net 00:00:04.3428384] Discovered: SomeProject
    2017-05-16T14:08:07.7242031Z
    2017-05-16T14:08:08.6299716Z Information: [xUnit.net 00:00:06.4120411] Starting: SomeProject

    But then none of the .Net Core Logging appears.

    I've searched everywhere and can't find a way to get the .Net Core logging to appear on the console when using vstest.console.exe.


    Tuesday, May 16, 2017 3:31 PM

All replies

  • Hi Joshua,

    Welcome to the MSDN forum.

    >> But then none of the .Net Core Logging appears.

    I try a test in my environment, and there’s logging appears.

    Please try to use following steps:

    1. Right click on the project in Solution Explorer and choose Manage NuGet Packages. Search for (and install) a package named xunit.runner.visualstudio

     2. Then, you could find the xunit.runner.visualstudio folder under packages of your solution.

     3. Open a command prompt, navigate to the root folder of your solution. To run the console runner, use a command like the one hightlighted below.

    Need add /TestAdapterPath

    Reference link: http://xunit.github.io/docs/getting-started-desktop

    Hope it helps.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Wednesday, May 17, 2017 7:45 AM
    Wednesday, May 17, 2017 7:45 AM
  • I'll give adding "/TestAdapterPath" a try, but I don't see any .Net Core logging (i.e. ILoggerFactory) going on in your example.  I'll let you know if the flag works.
    Wednesday, May 17, 2017 11:42 AM
  • I tried this, and the console output looks exactly the same.  I also checked the TRX file in the "stdout" element, and it's a duplicate of the console output.
    Wednesday, May 17, 2017 1:53 PM
  • Hi Joshua,

    Thanks for your feedback. 

    Sorry about the misunderstanding. Yeah, the TRX file I got is same as the console shows, same as yours.

    It seems there the compatibility between vstest.console.exe and dotnet.ext, and to be honest I still could find out if the vstest.console.exe could support the logging in xunit.

    But I share the result as soon as I figure it out.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, May 22, 2017 6:44 AM