How do I turn off the verbose logging in swagger-codegen? - swagger-codegen

I upgraded to swagger-codegen 3.0.10, and all of a sudden there's a ton of debugging output to the screen. There seems to be no command-line option to turn it off.
Does anyone know how to turn off the debugging output?

Figured it out. Swagger-codegen uses Logback for logging, and so we need to change its config file.
Step 1: Create a file logback.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<logger name="io.swagger" level="warn"/>
</configuration>
Step 2: swagger-codegen is actually a script that invokes java with the appropriate jar. You can edit the command (or invoke java directly from the command line) and include the following in the command line:
-Dlogback.configurationFile=./logback.xml
assuming logback.xml file is in your local directory. Of course, change the path if it's in a different directory.
For example:
java -Dlogback.configurationFile=./logback.xml -jar /usr/local/Cellar/swagger-codegen/3.0.10/libexec/swagger-codegen-cli.jar ...[other options]
This will turn off the verbose output. You can set other levels as you like - just replace 'warn' in the logback.xml file.

Related

Apache Ant Build output to file using only log4j

I am developing a java project using Eclipse as IDE and ant as the build tool. For logging I am making use of log4j library. I am able to get the log messages in a log file for my whole application using log4j configuration. But when I build project using ANT, the ANT build messages are still posted to console.I want to make sure that when I build the project, the build messages that ANT generates, like build failure/success, should also be posted to that sames logger file using log4j.
Please help me in this if anyone has got an idea in detail. Thanks
You can make use of Log4jListener available in ant.
Your log4j.properties file would look something like this
log4j.rootLogger=ERROR, LogFile
log4j.logger.org.apache.tools.ant.Project=INFO
log4j.logger.org.apache.tools.ant.Target=INFO
log4j.logger.org.apache.tools.ant.taskdefs=INFO
log4j.logger.org.apache.tools.ant.taskdefs.Echo=WARN
log4j.appender.LogFile=org.apache.log4j.FileAppender
log4j.appender.LogFile.layout=org.apache.log4j.PatternLayout
log4j.appender.LogFile.layout.ConversionPattern=[%6r] %8c{1} : %m%n
log4j.appender.LogFile.file=build.log
And you when you run the ant build you have to pass the listener argument as follows -
ant -listener org.apache.tools.ant.listener.Log4jListener
For the above command to work your log4j.porperites and the log4j jar sould be on the ant classpath. This way your build logs will go to both console and the file build.log

TFS2013 Git multi-project automated build web.config transform not working

I can't get MS Build to output a transformed Web.Config file. I've setup the build project using NuGet package restore as described in the NuGet docs. Every part of the build works (package restore, CI, web deploy packages) except for the transform. I have tried the base setup and a custom project file as well as lot of other options and I haven't gotten anywhere.
I've done config transform setups before without issue. I have Slow Cheetah installed and can preview my current transform and see that it works. When I run the build locally via MSBuild.exe, the transform actually happens:
TransformWebConfigCore:
Transforming Source File: G:\MyProject\Web.config
Applying Transform File: G:\MyProject\Web.Debug.config
Output File: obj\Debug\TransformWebConfig\transformed\Web.config
Transformation succeeded
(If I look at the -v output I can see the individual transform run)
Then Web Deploy parameterizes my web.config:
Transformed Web.config using G:\MyProject\Web.Debug.config into obj\Debug\TransformWebConfig\transformed\Web.config.
PipelineTransformPhase:
Publish Pipeline Transform Phase
PreAutoParameterizationWebConfigConnectionStrings:
Creating directory "G:\MyProject\obj\Debug\CSAutoParameterize\transformed\Views\".
Copying obj\Debug\TransformWebConfig\transformed\Web.config to obj\Debug\CSAutoParameterize\original\Web.config.
AutoParameterizationWebConfigConnectionStringsCore:
Transforming Source File: G:\MyProject\Views\Web.config
Applying Transform File: <?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add
connectionString="{% token='$(ReplacableToken_#(parameter)_#(tokennumber))' xpathlocator='name' parameter='$(name)-Web.config Connection String' description='$(name) Connection String used in web.config by the application to access the database.' defaultValue='$(connectionString)' tags='SqlConnectionString' %}"
xdt:Transform="SetTokenizedAttributes(connectionString)" xdt:SupressWarnings="True" />
</connectionStrings>
</configuration>
No element in the source document matches '/configuration/connectionStrings'
Not executing SetTokenizedAttributes (transform line 6, 15)
Output File: obj\Debug\CSAutoParameterize\transformed\Views\Web.config
Transformation succeeded
PostAutoParameterizationWebConfigConnectionStrings:
Auto ConnectionString Transformed obj\Debug\TransformWebConfig\transformed\Web.config into obj\Debug\CSAutoParameterize\transformed\Web.config.
The parameterized file is then moved into the package and the transformed file is deleted.
Copying obj\Debug\CSAutoParameterize\transformed\Web.config to obj\Debug\Package\PackageTmp\Web.config.
Deleting file "obj\Debug\CSAutoParameterize\transformed\Web.config".
So I have a transformed web.config file that doesn't end up in my build output. Why does the transform happen but not get copied to the output directory or the web deploy package?
I had the same issue here. This is caused by the Web Deploy Pattern. It uses the "project name".SetParameters.xml in the Web_Package to replace values on Deploy.
Since you want to use SlowCheetah you need to circumvent this.
You can accomplish this by replacing the connectionstrings setting in your web.config by:
<connectionStrings configSource="connectionStrings.config">
</connectionStrings>
Of course you will need the connectionStrings.config file. You van create this manually and put in the originasl connectionStrings section.
The node should be the only node in the file.
Now you can add SlowCheetah Transform on your connectionStrings.config file.

What are the pom.xml and log4j.properties under Apache CXF for?

I am new to Webservices and I need to know what the pom.xml and log4j.properties files are for in an Apache CXF project. I read the POM is used to represent a Maven project so it holds configuration files, dependencies etc. Is that correct? Why would I use Maven bulid instead ob sinpl runnig it as a Java application. And what is the .properties file for?
Thanks for any help.
You are correct about the POM file. It is a "Project Object Model" that holds the configuration files, dependencies. I use it because you can do a mvn clean install, instead of doing it separately, it splits the code into modules, dependency-relationships and versions.
log4j.properties is an open source API that is used to specify where you want your logs to be redirected. For example:
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
will make all your logs be output in the console.
If you want it to be saved in a file, use:
log4j.rootLogger=INFO, file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\loging.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
pom.xml is used to build (ex. create .jar files) the project using Maven. It it not used at runtime.
log4j.properties is a runtime configuration, that defines what logging information should be written and where. Check out these examples: http://www.mkyong.com/logging/log4j-log4j-properties-examples/

GCovr does not generate a valid report

I want to set up my Jenkins with Cobertura to track code coverage.
Unfortunately I can not generate a valid xml.
I'm using:
gcovr 2.5-prerelease (r2774)
Xcode 4.6.1 Build version 4H512
My project is generating code coverage files correctly, but the report created with gcovr is not useful.
The command I use to generate the report is:
gcovr -r /Users/Shared/Jenkins/Home/jobs/CodeCoverage/workspace
--object-directory /Users/Shared/Jenkins/Home/Library/Developer/Xcode/DerivedData/myProject-aooceqwwovrizceerghqvhflcfty//Build/Intermediates/myProject.build/Development/myProject.build/Objects-normal/x86_64
--exclude '.*Developer.*'
--exclude '.*Tests.*'
--xml
This will create me this output:
<?xml version="1.0" ?>
<!DOCTYPE coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
<coverage branch-rate="0.0" line-rate="0.0" timestamp="1364322914" version="gcovr 2.5-prerelease (r2774)">
<sources>
<source>
/Users/Shared/Jenkins/Home/jobs/CodeCoverage/workspace/Project/myProject/
</source>
</sources>
<packages/>
</coverage>
Additional Informations:
If I remove --object-directory and -r and then I execute the command from the derived data directory a valid report is generated. This report can be read from cobertura but can not show any detailed information about the source files.
When working with XCode, I've found that using $WORKSPACE/build as the build directory helps with this problem. This keeps the Derived Data directory out of it, and also neatly keeps my object files in the build directory. It also prevents two builds from interfering with each other.
If using the Xcode build tool, set SYMROOT to $WORKSPACE/build in the Tool's build configuration. If you're building from the command line, set it manually on the command line or in the environment.
Then a gcovr script such as:
/your/path/to/gcovr -r . --object-directory build/YourApp.build/Coverage-iphonesimulator/YourApp.build/Objects-normal/i386 --xml > build/coverage.xml
(your path may vary slightly depending on what you call your build style, etc.)
And finally in the Cobertura config, point at build/coverage.xml, and you should get annotated source when you use the tool within Jenkins.
Should do the trick. I've been really happy with that configuration on our small farm of Mac Minis.
gcovr should be executed from the folder where the .gcda and .gcno files exist. And the root path is the folder where the source files(.c or .cpp) exist.
With this, the command looks like something as shown below.
rr-mac:gcdaFolder$ gcovr -r /path_to_C_sourceFiles/ .
For output html file below command works
rr-mac:gcdaFolder$ gcovr --html -o Filename_rp.html -r /path_to_C_sourceFiles/ .
Note: The dot(.) at the end is mandatory
The gcovr python script does not appear to supports out of source tree builds.
I raised a bug report about this here https://github.com/gcovr/gcovr/issues/61

Pass parameters via the command line to NUnit

Is it somehow possible to pass values to NUnit tests via the command line?
My tests use a certain URL. I have different instances of my code at different URLs and would like to specify the URL via the command line. File App.config is not an option, because I want to run the tests for different URLs via a batch file.
Use an environment variable to pass the information.
Use set from the command-line or <setenv> from NAnt. Then read the value using Environment.GetEnvironmentVariable().
NUnit 3 now allows passing parameters. Here is the usage
nunit3-console [inputfiles] --params:Key=Value
From the documentation
--params|p=PARAMETER
A test PARAMETER specified in the form NAME=VALUE for consumption by tests. Multiple parameters may be
specified, separated by semicolons or by repeating the --params option
multiple times. Case-sensitive.
Here's how you can access the parameter through code:
var value= TestContext.Parameters.Get("Key", "DefaultValue");
There seems to be no solution at the moment. The best option is to use NUnit project files, modify settings there and pass the solution file to the runner.
I had a similar issue. The answer of Achim put me on the right track, and for other readers:
Create a file, like example.nunit, like this:
<NUnitProject>
<Settings activeconfig="local"/>
<Config name="local" configfile="App.config">
<assembly path="bin\Debug\example.dll"/>
</Config>
<Config name="dev" configfile="App.Dev.config">
<assembly path="bin\Debug\\example.dll"/>
</Config>
<Config name="test" configfile="App.Test.config">
<assembly path="bin\Debug\\example.dll"/>
</Config>
</NUnitProject>
All the file / paths (of the configuration and assembly files) are relative to the location of the NUnit file. Also the App.config, App.Dev.config, etc. file are just .NET configuration files.
Next when you want to run it for a certain configuration you execute it like this:
nunit3-console.exe example.nunit /config:test
More information about the format of the NUnit file is in NUnit Project XML Format.
More information about command-line arguments is in
http://www.nunit.org/index.php?p=consoleCommandLine&r=2.2.5