diff --git a/docs/debugging.md b/docs/debugging.md index c693e7fca2d3..1cc3e2ce64df 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -169,11 +169,16 @@ openapi-generator generate -g go \ Or you can add these to your `JAVA_OPTS` environment variable (this applies to every invocation of the tool): ```bash -export JAVA_OPTS="${JAVA_OPTS} --global-property debugModels,debugOperations" +export JAVA_OPTS="${JAVA_OPTS} -Dlog.level=debug --global-property debugModels,debugOperations" ``` > NOTE: Globally available system options like these will apply to all invocations of the generator (CLI and plugins) +> NOTE: If you invoke the tool via Java, you will need to provide the options directly to the `java` and `openapi-generator generate` command-line instead, for example: +``` +java -Dlog.level=debug -jar .../openapi-generator-cli.jar generate --global-property debugModels,debugOperations ... +``` + ## Runtime When you're working with a custom generator, a new generator, or otherwise trying to understand the behavior of the toolset, you may need to attach a remote debugger in order to step through the code. @@ -226,6 +231,11 @@ You can try to enable debugging log with `-Dlog.level=debug` option to the `JAVA export JAVA_OPTS="${JAVA_OPTS} -Dlog.level=debug" ``` +> NOTE: If you invoke the tool via Java directly, you must provide the property directly to its command line, for example: +```bash +java -Dlog.level=debug -jar ... +``` + Set the option then DEBUG logs are printed out: ```bash diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 32e007608571..613e04d4f576 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -604,7 +604,7 @@ void generateModels(List files, List allModels, List unu } if (GlobalSettings.getProperty("debugModels") != null) { LOGGER.info("############ Model info ############"); - Json.prettyPrint(allModels); + LOGGER.info(Json.pretty(allModels)); } } @@ -841,7 +841,7 @@ void generateApis(List files, List allOperations, List files, List allWebhooks, List buildSupportFileBundle(List allOperations, Li if (GlobalSettings.getProperty("debugSupportingFiles") != null) { LOGGER.info("############ Supporting file info ############"); - Json.prettyPrint(bundle); + LOGGER.info(Json.pretty(bundle)); } return bundle; }