If I launch
mvn clean
I am getting zero output, as if I demand only for WARNING only
But I have the default simplelogger.properties file:
org.slf4j.simpleLogger.defaultLogLevel=info
org.slf4j.simpleLogger.showDateTime=false
org.slf4j.simpleLogger.showThreadName=false
org.slf4j.simpleLogger.showLogName=false
org.slf4j.simpleLogger.logFile=System.out
org.slf4j.simpleLogger.cacheOutputStream=true
org.slf4j.simpleLogger.levelInBrackets=true
org.slf4j.simpleLogger.log.Sisu=info
org.slf4j.simpleLogger.warnLevelString=WARNING
I have tried to put defaultLogLevel and warnLevelString to DEBUG, WARN( I had noticed difference in behaviour for that writing before) and info. But always I have the same zero output.
mvn -X
gives the correct debug level of output, but I don't need it, I need normal info level, and what is the most important, I want maven to behave up to the configuration. What could happen?
Restarts and Maven erasing and reinstalling were tried.
If I introduce into the project something that causes a warning, I see it in the output. The same for the error. It seems that Maven remembers somehow that logger was set to WARN level sometimes (and it really was) and cannot forget and change that state.
I had set the
MAVEN_OPTS= -Dfile.defaultLogLevel="WARN"
It overcomes the settings in the simplelogger.properties file.
Related
Firing mvn clean test
prints this:
Due to some conditions I skip tests dynamically.
However, I'd like to print the cause for skipping to the console, like it's done for failing tests:
is there any way to archieve this?
Alternativly, how could I properly log it, so it's still recognizable between all the other logs?
I'm using log4j for logging. Any Ideas?
Along the lines of this answer (which works for me, BTW) and the javadocs, I tried
gradle.startParameter.consoleOutput = org.gradle.api.logging.configuration.ConsoleOutput.Rich
in my ~/.gradle/init.gradle. However, I still need --console=rich to get color output. Why?
Tested with Gradle 2.14.1 and 3.2.1.
Terminal is cygwin urxvt with TERM variable set to rxvt-unicode-256color.
Since Gradle 4.3 you can use org.gradle.console property in gradle.properties:
org.gradle.console=rich
A new console verbose mode will print outcomes of all tasks (like UP-TO-DATE) like Gradle 3.5 and earlier did. You can set this via --console=verbose or by a new Gradle property org.gradle.console=(plain rich verbose).
I am not sure if you can force the rich console from a gradle script, as the detection happens likely before the script is interpreted.
NativeServices class provides the integration with the console. If you look at the source code, there are two messages possibly printed in log:
Native-platform terminal integration is not available. Continuing with fallback.
Unable to load from native-platform backed ConsoleDetector. Continuing with fallback.
The latter might give you more information why. Try running the gradle script with --debug. You will likely find out that you are missing a native library that is either not available in cygwin or it is, but is not on library path.
I believe it works when you specify the rich console from the command line, because gradle forces the colours even though the console doesn't indicate it supports them.
Does it work if you don't use the cygwin console in Windows native command line or maybe GitBash?
There is a workaround how you can make this work. You can create an alias in cygwin that will always add the --console=rich.
If you are using gradle wrapper, you can edit the gradlew script and add the command line parameter. To make it automated, you can change the wrapper task to alter your script in the doLast part.
Create a file called gradle.properties inside your ~/.gradle/ folder.
Inside gradle.properties, add the line org.gradle.console=rich.
Each builds will run under --console=rich automatically because the new gradle.properties will be merged with the gradle.properties of your project.
If your project's gradle.properties contains the same tag as the local file, your project's will be used overriding the local file's
If you are on Linux/Mac set
alias gradle='gradle --console rich'
in your ~/.bashrc.
In Gradle Wrapper, add the following line:
org.gradle.console=rich
to ./gradle.properties in the root folder, where the gradlew script is located.
Due to the configuration I'm using, I get lots of these:
[WARNING] 'dependencies.dependency.systemPath' for local-deps:[...] should not point at files within the project directory, ${basedir}/[...] will be unresolvable by dependent projects [...]
Since this is how the application is currently setup, I can't fix them; but they clutter the console, so is there a way to disable them? mvn --quiet is not an option because it removes too many messages.
See the Maven 3.1.x logging documentation. You can configure the log level by editing the ${M2_HOME}/conf/logging/simplelogger.properties file. First set the value of org.slf4j.simpleLogger.showLogName to true and you will see the logname that prints your unwanted message. After that add the line org.slf4j.simpleLogger.log.a.b.c=error where a.b.c is the logname.
Maybe, this question is silly but I'm very new. I try to search without luck.
I got two errors when building maven project with sonar:
No information about coverage per test.
Although I had test code and these testing classes cover the code.
The global property 'sonar.doxygen.deploymentPath' is not set. Set it in SONAR and run another analysis.
I dont know it should be set where in sonar server. I set in web.xml or sonar-server.properties but it does not work.
Thanks.
About the first warning message this is not an error but a warning : since Sonar 3.5 this is possible to get the code coverage relating to each unit test. Here the message just says that this feature is not activated which is expected by default. Nevertheless I do agree that this warning message can be misleading.
About the second error message, I don't know the doxygen plugin but the message seems to be pretty clear : the sonar.doxygen.deploymentPath property has not be defined. See the plugin documentation : http://docs.codehaus.org/display/SONAR/Doxygen+Plugin.
Two things:
There is no war folder anymore since the sonarqube has given up tomcat support
The doxygen plugin is not implemented to upload the files in to the sonarqube server &/ installation, which means it only can be done by referencing the path inside your installation, e.g.:
run "mvn install sonar:sonar" in your project "/root/test.example.sonar.com"
in sonarqube set the cfg-key "sonar.doxygen.deploymentPath" the value: "/root/sonarqube-4.1.1/web/" and the cfg-key "sonar.doxygen.deploymentUrl" the value: "http://:9000"
have fun with your doxygen
Remember that the plugin will only be run through your mvn cmd, refreshing the page only will not do the job, you will have to analyse again after each cfg set :/
Check the file system and folder permission
I'm having issues with a test, which when executed in maven fails to initialize log4j, although a valid log4j.properties is in src/test/resources and therefore should end up on the classpath of the test. But it doesn't, i.e. log4j prints only
log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.
In order to debug the problem I printed the classpath from the test itself, using the code here
But instead of a lengthy list of jars and paths I just get
/<projectpath>/target/surefire/surefirebooter6226797341642271676.jar
So my questions are:
WTF is maven doing with the classpath?
Why doesn't my log4j.properties end up on the classpath?
How do I debug this?
Note: In Eclipse I can run the test just fine and everything works as expected.
Another note: the maven project is a multimodule project and I'm only executing a single test from a single submodule, with a commandline like this:
mvn -U -Dtest=de.company.project.SomeTest clean test
Have a good look at the maven-surefire-plugin. By default it creates a jar stuffed with your entire classpath. This is controlled by the useManifestOnlyJar option. This works around the problem of Windows having a classpath limit of 1024 (quoting off the top of my head). Under Linux you wouldn't really feel this pain much as the limit is much higher.
If you are forking the maven-surefire-plugin, it will use a different classpath than the one you're running Maven (and the compilation).
Debugging this kind of crappy situation can be done as follows:
In one of your tests add a loop that lists all the environment variables along with the java system properties.
Debug the tests:
mvn -Dmaven.surefire.debug="-Xdebug \
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9001 \
-Xnoagent" \
test
I found the answer to question 1.
Maven creates the jar with the weird name on the fly and just puts a MANIFEST.MF file in there. That file contains the classpath, and the main class to be started.
This also answers to some extend question 3.
You can copy that jar file somewhere else, while maven is running, so it does not delete it once it is finished. Then you can examine it as long as you want. Turns out my log4.properties is on the classpath (the target directories for the testclasses is there and the properties files is in that directory ....)
Leaves me with question 2.
It turned out somewhere in the forest of pom.xmls the system property log4j.configuration was set to a rather useless value. Setting that value back to the propervalue as described here solved my immediate problem.
Now I just have to find the broken spot in our poms, but that's a story for a different day.