I am using AKKA Typed 2.6.5 with AKKA HTTP...
and getting below error
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
I have imported every possible sbt repository and tested but still logging is not working.
Any help would be appreciated.
You need to add a dependency to an implementation of the SLF4J API. SLF4J is only an interface, and requires you to provide an implementation of your choice, as described in the documentation linked from the error message.
A popular implementation is Logback. You can include it in your project by adding it to your libraryDependencies:
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3"
You can configure it by adding a file at src/main/resources/logback.xml with contents like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>myapp.log</file>
<immediateFlush>false</immediateFlush>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>myapp_%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>[%date{ISO8601}] [%level] [%logger] [%marker] [%thread] - %msg MDC: {%mdc}%n</pattern>
</encoder>
</appender>
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>8192</queueSize>
<neverBlock>true</neverBlock>
<appender-ref ref="FILE" />
</appender>
<root level="INFO">
<appender-ref ref="ASYNC"/>
</root>
</configuration>
You can configure this to the needs of your application. See the Logback manual for details on configuration. Be sure to use an async appender as demonstrated above, so that logging doesn't result in blocking I/O on your Akka dispatcher threads.
There is more information in the Akka documentation at https://doc.akka.io/docs/akka/current/typed/logging.html#slf4j-backend
Related
I have just recently started using Continuous Integration with VSTS and I have set up a pipeline which includes the "Visual Studio Test" Task.
Within the task, there's an option to execute a code coverage scan as part of the test.
To ensure that my code coverage only covers MY code and have a) created a .RunSettings file to include only the assemblies I generate and b) there are some parts of the code with the [ExcludeFromCodeCoverage] attribute.
Now, when execute Analyze Code Coverage from Visual Studio (2017 Enterprise, 15.7.4), everything works as I would expect, only my assembly gets analyzed and the code I have excluded is, errr, excluded.
However, when the VSTS pipeline is run, no such limitations are applied and ALL assemblies are tested and ALL code, including the specifically excluded code, which then results in a dramatic drop on the code-coverage %age.
Not sure where to go from here so hoping the S/O community can help.
Update - RunSettings file in use
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*Tests.dll$</ModulePath>
<ModulePath>.*moq.dll$</ModulePath>
</Exclude>
</ModulePaths>
<UseVerifiableInstrumentation>False</UseVerifiableInstrumentation>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
There is an issue here: RunSettings file not used in TFS VsTest task, you can go and check the discussion about this issue.
As a workaround you can use below .RunSettings formats (add the UseVerifiableInstrumentation = False)
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<UseVerifiableInstrumentation>False</UseVerifiableInstrumentation>
<ModulePaths>
<Include>
<ModulePath>.*\\MyProjectName.*\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*Tests.dll$</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
Just check acesiddhu's explanation:
you are using visual studio test tools installer task in your
definition. in case that task is used useverifiable property needs to
be set to false because in xcopy mode we don't GAC the above dll
'Microsoft.VisualStudio.CodeCoverage.Shim (this is a dependency which
needs to be loaded when useverifiable is set to true)
marking this property false ensures it doesn't use this particular
dll.
Goal
I want to be able to run my unit tests remotely on another machine since they interact with the UI of another application. For clarity these tests are not Coded UI Tests, they are tests methods that use FlaUI to interact with the desktop.
Problem
I can't get the Visual Studio Test Controller and Test Agent to work with MSTest V2. When I set the .runsettings file to use the .testsettings file and to ForcedLegacyMode like the documentation says here I get the following warnings and no tests are loaded into the test explorer.
[11/22/2017 9:54:12 AM Warning] Index was outside the bounds of the array.
[11/22/2017 9:54:13 AM Warning] Index was outside the bounds of the array.
[11/22/2017 9:54:13 AM Warning] Index was outside the bounds of the array.
[11/22/2017 9:54:14 AM Warning] Warning : A testsettings file or a runsettings with a ForcedLegacyMode set to true is not supported with the MSTest V2 Adapter.
I am hoping I am just missing some setting I can put into my .runsettings file that will allow me to specify the url for my Test Controller.
Settings
Here are my .runsettings and .testsettings files for reference. These settings successfully connect to the machine but when I build my test runner no longer finds and tests to run.
.runSettings
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
<!-- Path relative to solution directory -->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<!-- [x86] | x64
- You can also change it from menu Test, Test Settings, Default Processor Architecture -->
<TargetPlatform>x86</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
</RunConfiguration>
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>
<!-- We recommend you do not change the following values: -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<!-- Parameters used by tests at runtime -->
<TestRunParameters>
</TestRunParameters>
<!-- Adapter Specific sections -->
<!-- MSTest adapter -->
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
</MSTest>
</RunSettings>
.testsettings
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="rmoqa01" id="076be28c-d18b-46bf-ad20-4d43ec821ea4" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>These are default test settings for a local test run.</Description>
<RemoteController name="10.2.0.101" />
<Execution location="Remote">
<Hosts skipUnhostableTests="false">
<VSSDKTestHostRunConfig name="VS IDE" HiveKind="DevEnv" HiveName="15.0_c9b36733" xmlns="http://microsoft.com/schemas/VisualStudio/SDK/Tools/IdeHostAdapter/2006/06" />
</Hosts>
<TestTypeSpecific>
<UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
<AssemblyResolution>
<TestDirectory useLoadContext="true" />
</AssemblyResolution>
</UnitTestRunConfig>
</TestTypeSpecific>
<AgentRule name="AllAgentsDefaultRole">
</AgentRule>
</Execution>
<Properties />
</TestSettings>
I opened a issue on the mstest github page and after looking at the source code generating my warning I am seeing it looks like there is probably no work around to this. Here is the source code I was looking at in the MSTestDiscover.cs.
// Scenarios that include testsettings or forcing a run via the legacy adapter are currently not supported in MSTestAdapter.
if (MSTestSettings.IsLegacyScenario(logger))
{
return;
}
EDIT: 10/28/2018
The issue I linked to above was updated with the following response.
There are no plans to have remote execution capability through MSTVest2. You can use the test task in VSTS which supports distributed execution on multiple agents. https://learn.microsoft.com/en-us/vsts/pipelines/test/set-up-continuous-test-environments-builds?view=vsts
Is there a possibility, in any language (c/c++/c#,VB etc I DONT CARE) to export all the COM Registration information (such as clsid, progid, typelib, interface, appid etc)? Or do you know a reliable tool that exports that information including all of the 32 bit and 64 information?
Basically what I wanna do is what regsvr32 does but "in a file" and not write it to the registry. The solution can be a API-Call or Assembly class OR ANYTHING that supports me by doing this or it can be a tool where you are able to export the infos to a file. Please be aware that the tool, if so, should do this for COM as well as for interop assemblies.
(I am not interessted in wisecomcaputure or the equivalent of adminstudio)
For clarification my point is here:
I am a setup engineer. I basically want to know a way to get all the registration information of a COM or an Interop Object that's normally placed in the registry by calling regsvr32.
I am very glad of any help or hints
Eliane
There is a little-known but very handy API: RegOverridePredefKey. It allows to do exactly what you're looking for:
The RegOverridePredefKey function is intended for software
installation programs. It allows them to remap a predefined key, load
a DLL component that will be installed on the system, call an entry
point in the DLL, and examine the changes to the registry that the
component attempted to make. The installation program can then write
those changes to the locations intended by the DLL, or make changes to
the data before writing it.
Follow the docs for further details. Once you have re-mapped the HKEY_CLASSES_ROOT key and called the COM server's DllRegisterServer, use RegSaveKey to save the re-mapped key to a file, process the file and change the mapping back to HKEY_CLASSES_ROOT.
We use WiX in our company to create installers and gathering this registry information for COM assemblies is often essential in the installation process. Within the WiX suite there is a tool called Heat that basically scrapes this information and puts it in an xml file. This xml is specific to WiX but it may still help you.
An example heat command to do this would be:
C:\Program Files (x86)\WiX Toolset v3.8\bin\Heat.exe dir ..\ExactaRFBinaries\ -cg ExactaRF -dr RFINSTALLFOLDER -srd -var var.RFBasePath -gg -sfrag -suid -out ExactaRF.wxs
It's output would look something like this:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="RFINSTALLFOLDER">
<Component Id="ContainerObj.dll" Guid="{A23592C5-E88D-4F56-A853-AE62085F9A91}">
<File Id="ContainerObj.dll" KeyPath="yes" Source="$(var.RFBasePath)\ContainerObj.dll">
<TypeLib Id="{8EB27E71-FA87-11D3-A3B3-00104B082353}" Description="ContainerObj 1.0 Type Library" HelpDirectory="RFINSTALLFOLDER" Language="0" MajorVersion="1" MinorVersion="0">
<Class Id="{2F467C72-FE8A-11D3-A3B7-00104B082353}" Context="InprocServer32" Description="Containers Class" ThreadingModel="apartment" Programmable="yes">
<ProgId Id="ContainerObj.Containers.1" Description="Containers Class">
<ProgId Id="ContainerObj.Containers" Description="Containers Class" />
</ProgId>
</Class>
<Class Id="{8EB27E80-FA87-11D3-A3B3-00104B082353}" Context="InprocServer32" Description="Container Class" ThreadingModel="apartment" Programmable="yes">
<ProgId Id="ContainerObj.Container.1" Description="Container Class">
<ProgId Id="ContainerObj.Container" Description="Container Class" />
</ProgId>
</Class>
<Interface Id="{2F467C71-FE8A-11D3-A3B7-00104B082353}" Name="IContainers" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
<Interface Id="{8EB27E7F-FA87-11D3-A3B3-00104B082353}" Name="IContainer" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
</TypeLib>
</File>
</Component>
<Component Id="ContainerUseMod.dll" Guid="{48616A97-02AA-4C02-AC5D-F41313B3C0F2}">
<File Id="ContainerUseMod.dll" KeyPath="yes" Source="$(var.RFBasePath)\ContainerUseMod.dll">
<TypeLib Id="{7590DB15-C326-11D3-99A9-0080C84E7C62}" Description="ContainerUseMod 1.0 Type Library" HelpDirectory="RFINSTALLFOLDER" Language="0" MajorVersion="1" MinorVersion="0">
<Class Id="{7590DB22-C326-11D3-99A9-0080C84E7C62}" Context="InprocServer32" Description="ContainerUse Class" ThreadingModel="apartment" Programmable="yes">
<ProgId Id="ContainerUseMod.ContainerUse.1" Description="ContainerUse Class">
<ProgId Id="ContainerUseMod.ContainerUse" Description="ContainerUse Class" />
</ProgId>
</Class>
<Interface Id="{7590DB21-C326-11D3-99A9-0080C84E7C62}" Name="IContainerUse" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
</TypeLib>
</File>
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ExactaRF">
<ComponentRef Id="ContainerObj.dll" />
<ComponentRef Id="ContainerUseMod.dll" />
</ComponentGroup>
</Fragment>
</Wix>
WiX is open source so you could probably look at the Heat source code if you want and engineer your own solution as well.
Yes, this is possible. However, the only tool I know of is proprietary and used internally within my company. I'm not sure exactly how it does it and I can't give out the source, unfortunately.
From poking around in the source, it seems like it's getting all the resources of COM DLLs and doing something with the resources, and it's pulling out some info from the type libraries (it's a command-line program that can be given a dll or a tlb).
The code is written in C++ and C# and is about 1400 LOC.
The code makes use of the COM interfaces ITypeLib and ITypeInfo and the TYPEATTR structure. I see calls to ITypeInfo::GetDocumentation, ITypeInfo::GetTypeAttr, LoadTypeLibEx, EnumResourceNames. The output of the program is a .reg file, which appears to be formatted by the tool's code rather than an external library.
We found a little utility called RegCap that Microsoft included with a visual studio extension called Visual Studio Installer Projects. The overall package can be downloaded from the Visual Studio Marketplace (it's a vsix file) here:
https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2017InstallerProjects
I've had a brief play and it certainly seems to extract the COM registration information. Whether it extracts all the information that regsvr32 would have put into the registry is another matter.
I'm working on an internal ivy repository with a decent number of projects under it, each with many revisions. I would like to make a dependency report for the entire repository showing which versions of which artifacts depend on which revisions of other artifacts. Obviously it isn't too difficult to make a script to parse the published ivy xml files, but if this functionality exists already I'll use that. Something like the repreport task would be nice, but for a whole repo.
My main goal here is to get a report of artifacts that are not referenced by any other artifacts so as to make a list of candidates for removal from the repo.
So, does ivy have any way to build a dependency report against and entire repository?
Edit: Working through this, it looks like ivy:repreport is the way to go.
Here is my build.xml file:
<project name="Report Build" xmlns:ivy="antlib:org.apache.ivy.ant" basedir=".">
<property name="ivy.version" value="2.2.0"/>
<property name="ivy.home" value="${user.home}/.ivy2"/>
<target name="fetch-ivy" unless="offline" description="Install Ivy if it doesn't already exist">
<mkdir dir="${ivy.home}"/>
<get
src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"
dest="${ivy.home}" usetimestamp="true"/>
</target>
<target name="init-ivy" depends="fetch-ivy" unless="ivy-initialized">
<path id="ivy.lib.path">
<fileset dir="${ivy.home}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
<property name="ivy-initialized" value="yes"/>
</target>
<target name="report" depends="init-ivy">
<ivy:settings file="ivy-settings-report.xml" id="report.ivy.settings"/>
<ivy:repreport settingsref="report.ivy.settings"/>
</target>
</project>
And here is my ivy settings file:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-settings>
<settings defaultResolver="main"/>
<resolvers>
<chain name="main">
<url name="internalartifacts" m2compatible="false">
<artifact
pattern="http://internalartifacts.local/[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
<ivy pattern="http://internalartifacts.local/[organization]/[module]/[revision]/ivy-[revision].xml"/>
</url>
</chain>
</resolvers>
</ivy-settings>
The documentation for repreport says:
To generate a xml report for all the latest versions of all the
modules in your repository:
<ivy:repreport />
Limitation: this task requires to be able to browse the repository,
and is thus limited to resolvers supporting repository listing. In
particular, it means it doesn't work to report all organizations in a
repository using m2compatible mode. Moreover, to be able to list
organizations, this task requires an [organisation] token in the
resolver(s) used.
So this should totally work.
As mentioned in the comment:
It is important that your repository has ivy.xml files for the artifacts in it. Otherwise ivy cannot recognize the dependencies between the artifacts and your report will be empty.
I am trying log some entries in a log file (Log.Trace / Log.Debug) while my VS unit test runs. I have also copied the file NLog.config to out directory through DeploymentItem attribute over class. Still my log file is not created. Any help as to how can we log entries in a file same as we do for normal web application.
I've just found a solution to this problem:
Add the App.config file to yout unit test project with the following contents:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="debugLog" xsi:type="Console" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="debugLog"></logger>
</rules>
</nlog>
</configuration>
You may put any configuration you wish as with NLog.config file.
Unfortunately that is the only XML solution at the time. It is not only about Unit Testing, though. NLog.config does not work with just any Console Application.
Do not know if it is by design or just an oversight. Anyway I would not say that moving NLog.config to App.config section is any way satisfactory =/
Maybe it is worth to notice that there is a possibility of configuring nlog directly from code, what could be helpful in some scenarios.
One could be also glad to find nlog debug option, that will log the whole process of processing configuration file, registering targets and so on...
To turn it on, just add internalLogFile and internalLogLevel attributes to nlog element:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogFile="C:/logs/nlog.txt" internalLogLevel="Debug">
or from code:
InternalLogger.LogFile = #"c:\logs\nlog.txt";
InternalLogger.LogLevel = LogLevel.Trace;