NUnit - how to include logging - nunit

Any Sample on NUnit default logger to log the information. Some documentation says log4net is not supported now. Appreciate your help.
Thanks,kumar.

You can use the normal .NET Trace or Debug classes to log messages that NUnit will later display.

You can add Common.Logging reference (with log4net) and add ConsoleAppender in your configuration file. After configuring the appender you will see logging information when running your unit tests.

Related

Citrus Framework - echo action does not "echo"

I am attempting to debug/trace an integration test written with the Citrus Framework. Among the various test "actions" that can be taken, there is an echo action which is supposed to do what you might expect: echo something to the console log. The problem is: it does not echo.
When I run the integration test (via Maven failsafe plugin), errors from the test failing appear on the console, but nothing else.
What am I missing?
UPDATE:
This appears to only be a problem when running the integration tests as part of a maven build. When the test is run from eclipse, the complete console log appears.
This may be an issue with your test names. Failsafe Maven plugin by default has a naming convention and only runs those tests that follow this convention. So your test names must match a pattern.
Please review the default naming pattern in failsafe plugin and see if this fixes your issue.
I was able to figure out how to get logging to capture the Citrus integration test console output. See related issue Citrus Framework logging - how to enable/use.

Getting PostSharp 6.0.32 and Log4Net 2.0.0 to log at a custom level

We are using PostSharp with Log4Net as a back end. I am trying to get PostSharp to log at a different level to our manually added log statements which are at DEBUG level.
I've tried setting the postsharp.config file option below:
<LoggingProfile Name="default" IncludeSourceLineInfo="True">
<DefaultOptions>
<LoggingOptions Level="Trace"/>
</DefaultOptions>
</LoggingProfile>
But that doesn't seem to work.
I've overridden the Log4NetLoggingBackend to try and intercept the Trace level but it seems that when setting the PostSharp level to Trace, it doesn't hit any of the custom backend code.
Have I missed out a crucial step?
The configuration snippet shown in the question looks correct. Please note, however, that in the configuration file you set the PostSharp logging level that is then mapped to the logging level of the target logging back-end (log4net in this case). Both LogLevel.Trace and LogLevel.Debug map to the Debug level in log4net because the log4net library doesn't offer Trace level.
You can try to set level to Info to test that your configuration file works as expected.

Viewing log4net output when running nunit tests in teamcity

I'm setting up some selenium tests written in C# to run in teamcity. The tests output various info when running, I have a log4net rolling file appender on the project and when they run locally in VS or using the nunit test runner they write to a log file correctly. When running in teamcity this doesn't happen. Is it possible to get this working?
TeamCity version: 9.0.3
TeamCity Nunit runner: 2.6.4
Yes, TeamCity's build log is actually the console output, so you need to use log4net's ConsoleAppender.
Have a look at an example here on how to configure it.
https://logging.apache.org/log4net/release/config-examples.html
Also log4net allows multiple appenders to be used, so you can keep the rolling file appender as well if needed.

Slick logging with slf4j-simple

I am using slf4j-simple in my project. I would like to change logging level for slick to INFO. After reading Logging options for Slick
and Class SimpleLogger docsI have tried to add following options to my VM line:
-Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
-Dlogger.scala.slick=INFO
-Dlogger.scala.slick.jdbc.JdbcBackend.statement=INFO
-Dorg.slf4j.simpleLogger.log.scala.slick=INFO
I see a few INFO level logs comming from jetty, therefore the basic logging seems to be working. I am also able to change level of logs shown by using -Dorg.slf4j.simpleLogger.defaultLogLevel=TRACE, but even that only shows more jetty logs, no Slick logs are shown to me.
How can I configure slf4j-simple to shown slick logs to me?
According to http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html the correct system property should be
-Dorg.slf4j.simpleLogger.log.scala.slick=debug
instead of
-Dlogger.scala.slick=INFO
For reference, the list of all loggers used by Slick can be found in logback.xml. We only use the debug level with all of them.

Displaying results of an NUnit run, CruiseControl.Net 1.5.7256.1

We recently upgraded CruiseControl.Net 1.4.2 to 1.5.7256.1. To our dismay the nice nunit results page that had previously been there had disappeared. All we get now is a build log with the verbose output from command line of our build.
After some research we discovered you can log into "Dashboard Administrator" from the main ccnet dashboard page and install the NUnit package. However, this did not change the output of our builds to include a NUnit result page.
Is there something extra we need to do here to have our output displayed? Any help would be greatly appreciated. I don't goto stack overflow until I've exhaustively searched on Google. I'm surprised no one else is confused or complaining about this.
FYI, we are merging our nunit XML output in the project configuration.
I'm not used to the Dashboard Administrator stuff, but you can edit the dashboard.config manually. Opposite to earlier versions CCNET version 1.5 comes with a naked configuration file.
Alternatively you may simply replace the configuration file with your 1.4 dashboard.config.
Possible duplicate of Cruise Control .net: Using packages and showing NUnit results
Don't merge manually if you use the nunit task
Edit the dashboard.config and the ccservice.exe.config files to add the nunit xsl files. Restart IIs.
Check that the Iis user has been granted access to the dashboard dir.