swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.03k stars 6.03k forks source link

How to change logging level via command line param ? #9587

Open unoexperto opened 5 years ago

unoexperto commented 5 years ago

Is there a way to change logging level via command line param ?

I see that it's set to DEBUG in config. It's very verbose.

I tried to make a copy of this file and pass -Dlogback.configurationFile=./logback.xml but it didn't help.

Thanks!

Pe-te commented 4 years ago

duplicate of #9513 ?

Otiel commented 4 years ago

I've also tried to set the log level via the logback.xml file, but it suppresses all output.

logback.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <logger name="io.swagger" level="warn"/>
</configuration>

Command line:

java -Dlogback.configurationFile=./logback.xml -jar ./swagger-codegen-cli-3.0.20.jar generate ...

Is this supposed to work?

Pe-te commented 4 years ago

does this help? #10139

smargoli2 commented 2 years ago

This is still not resolved, please can someone address this?

megretson commented 1 year ago

Pinging this issue again. The output is far too verbose by default.

PayBas commented 1 year ago

My workaround to reduce logging is this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>set-system-properties</goal>
            </goals>
            <configuration>
                <properties>
                    <property>
                        <name>org.slf4j.simpleLogger.log.io.swagger.codegen.v3.AbstractGenerator</name>
                        <value>warn</value>
                    </property>
                    <property>
                        <name>org.slf4j.simpleLogger.log.io.swagger.codegen.v3.generators.DefaultCodegenConfig</name>
                        <value>error</value>
                    </property>
                </properties>
            </configuration>
        </execution>
    </executions>
</plugin>

The exact property names to use will depend on your situation. You can identify which classes are producing your spam by using -Dorg.slf4j.simpleLogger.showLogName and prepending them with org.slf4j.simpleLogger.log.