How to disable Quarkus logging to a file (quarkus.log)? - quarkus

I would like to run my Quarkus app in a container where the best practice is to only log to the console and not to a file.
How can I do that?

To disable logging, edit your application.properties file and add the following property:
quarkus.log.file.enable=false

By default Quarkus logs to both the console and to a file named quarkus.log.
In cases where writing to the log file is not necessary (for example when running a Quarkus app in a Kubernetes Pod), quarkus.log.file.enable=false can be used.
This property can be set either in application.properties or be overridden at runtime (using -Dquarkus.log.file.enable=false).
See this guide for more information about logging.
UPDATE
With this PR, logging to a file is now disabled by default.

Related

What is the difference between setting profile in quarkus with smallrye.config.profile or quarkus.profile

In quarkus the config is stored inside an application.properties file.
You can have multiple application-{profile}.properties files. {profile} is the name of the profile you want it to be.
When started with java -jar <pathToJar> -Dquarkus.profile=PROFILE_ONE the file application-PROFILEONE.properties is used. During startup of the app you can read that quarkus is using the PROFILE_ONE profile.
When started with java -jar <pathToJar> -Dsmallrye.config.profile=PROFILE_ONE the file application-PROFILEONE.properties is used. During startup of the app you can read that quarkus is using the PROD profile.
What exactly is the difference between both? Is it better to use smallrye.config.profile so that quarkus is still using the PROD profile? Is the PROD profile faster?
Thanks!
That is actually a bug. Internally, both use the same profile, but the log is reporting a different one when you use smallrye.config.profile, because it is only checking for quarkus.profile and then it defaults to prod (later in the code the actual profile is checked and used the correct one).
The message needs to be fixed. I'll look into it.

Quarkus: How to define and read properties file (or application.properties) outside application or at runtime?

In Quarkus, We have properties file inside project itself called application.properties.
Is there any Quarkus way to define external properties file in my use case like i am developing a mail sender and i want to add recipients in future.
Is it possible to give application.properties outside at local and inject it at runtime?
You can add a configuration file in your application working directory under config/application.properties : https://quarkus.io/guides/config#overriding-properties-at-runtime
There is ongoing discussion to have more runtime configuration capabilities here: https://github.com/quarkusio/quarkus/issues/1218
You can achieve this by keeping .properties (or .yaml) in Spring Cloud Config Server.
It's really easy to set it up. It's is well documented in following link (official documentation):
Quarkus - Reading properties from Spring Cloud Config Server
As loïc says, you can follow the convention and create a config/application.properties. You can also use the property quarkus.config.locations to specify additional config locations. It can be defined at runtime like below
java -Dquarkus.config.locations=app-config/config.properties -jar my-app.jar

Possible to configure Jaeger via application.properties?

According to https://quarkus.io/guides/opentracing-guide all Jeager configuration is via JVM args (-DJAEGER_ENDPOINT...) but I'd like to use either application.properties or microprofile-config.properties to configure tracing. I've tried the following but the only config that seems to be picked up by Quarkus is the service-name all other properties are ignored.
quarkus.jaeger.service-name=my-service <-this one is working
quarkus.jaeger.endpoint=http://localhost:14268/api/traces <- seems to be ignored
quarkus.jaeger.reporter-log-spans=true
quarkus.jaeger.sampler.type=const
quarkus.jaeger.sampler.parameter=1
So, question is if it is possible to configure via config-files or this is not currently supported?
While doing mvnDebug quarkus:dev (without jvm.args) and placing a breakpoint here, I see that you all your params are being passed except quarkus.jaeger.sampler.parameter which is wrong.
It should be quarkus.jaeger.sampler.param

JHipster Registry cannot get logfile

I Have a JHipster monolith application running successfully along with JHipster Registry. Everything is fine, I can see my application instance and all metrics.
But I get the following hint under the tab Administration/Logs:
No available logfile.
Please check:
- if the microservice is up
- these properties are set:
- logging.path
- logging.file (to avoid using the same spring.log)
See:
- https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html
And a 404 Status response for /management/logfile
As already mentioned the service is running and in application-*.yml logging is set to
logging.file: /opt/tomcat/logs/shorty.log
The read permission for this file is shared by everyone.
Why I can't see the contents of the log file? Did I miss something?
Ok, my Spring Cloud Config was wrong. I had the additional logging.path property set.
But this seems not necessary with the default configuration. After removing this in application.yaml for JHipster Registry everything worked like a charm.

Actuator - custom logfile endpoint possible?

I have set up my log configuration using logback.
The configuration sets up my logs in a rolling manner in a custom location. This means that I'm not using either:
"logging.file" or "logging.path" in my application.yml configuration, and as a consequence, the logfile endpoint no longer works.
Does anybody know of a way to customize this endpoint, so that I can point to the location/file specified in my logback.xml configuration?
Reading the two sections on Logging 26 & 74. It looks like it recommends using the logback-spring.xml config file with the base.xml configuration. With that you can still use the logging.file or logging.path application properties within the configuration. That way the /logfile endpoint is still valid for the current log file (probably won't look into the rolling files if that is what you setup).
You can specify the log file source from which the actuator will read.
To do that, try to use this property in your application.properties
endpoints.logfile.external-file=/var/log/app.log
or (based on your springboot version):
management.endpoint.logfile.external-file=/var/log/app.log

Resources