FHIR Chat · How to Disable HAPI/FHIR Tomcat Logging? · hapi

Stream: hapi

Topic: How to Disable HAPI/FHIR Tomcat Logging?


view this post on Zulip Fran del Río (Dec 18 2020 at 19:00):

Hi everybody. I want to know how can I disable HAPI/FHIR logging in catalina.out Tomcat file.

I have a logback.xml file in WEB-INF directory. I’ve tried removing it but hapi continue logging in catalina.out. :worried:
I have managed to disable logging temporarily by removing JAR files "logback-classic" and "logback-core" from directory "hapigeosalud\WEB-INF\lib" but I would like to know how to do it correctly.

I need to disable hapi/fhir logging completly or know how to do it by a config file.

Thanks in advance!

view this post on Zulip James Agnew (Dec 18 2020 at 19:03):

I believe catalina.out automatically contains anything that is logged to the console by anything running within Tomcat.

So to stop HAPI FHIR from going there, assuming you have logback on your classpath, you need to explicitly configure logback.xml to not send anything to STDOUT.

view this post on Zulip Fran del Río (Dec 18 2020 at 19:13):

James Agnew said:

I believe catalina.out automatically contains anything that is logged to the console by anything running within Tomcat.

So to stop HAPI FHIR from going there, assuming you have logback on your classpath, you need to explicitly configure logback.xml to not send anything to STDOUT.

Hi James. This is my (original) logback.xml file:

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%-5relative %-5level %logger{35} - %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="jdbc" level="OFF" />

    <root level="ERROR">
        <appender-ref ref="STDOUT" />
    </root>
</configuration>

I have edited this file several times but it keeps logging. What should I add or remove to stop logging?

view this post on Zulip James Agnew (Dec 18 2020 at 22:05):

Hmm, assuming it's picking that file up you could remove the appender.

If that doesn't work, watch for any error messages from logback when it starts. Failing all else, you could try having it log what it's using as startup source. There are some details here: https://stackoverflow.com/questions/18922730/how-can-i-determine-what-log-configuration-source-logback-actually-used

view this post on Zulip Fran del Río (Dec 21 2020 at 11:56):

James Agnew said:

Hmm, assuming it's picking that file up you could remove the appender.

If that doesn't work, watch for any error messages from logback when it starts. Failing all else, you could try having it log what it's using as startup source. There are some details here: https://stackoverflow.com/questions/18922730/how-can-i-determine-what-log-configuration-source-logback-actually-used

Thanks again but I can't find current log config. It isn't in logback.xml, I deleted it, I commented appenders and it continue logging.

I don't know what setting hapi may be using to disable it. The amount of log messages that make tomcat's own messages difficult to read is stressful. I am attaching a copy of messages just 1 minute after starting the tomcat service. catalina-hapi.txt

view this post on Zulip James Agnew (Dec 21 2020 at 15:58):

The fact that there are debug messages in there certainly kinda suggests to me that it's not using your logback.xml file. Possibly because it's finding another one or possibly because it is finding another binding altogether.

You could try grepping your catalina.out for the string "slf4j" - if SLF finds multiple bindings it'll print a warning on the console when it first starts.

You could also try adding the following system property -Dlogback.debug=true to your startup args, this will cause logback to print debug details as it bootstraps.

view this post on Zulip Fran del Río (Dec 21 2020 at 19:06):

James Agnew said:

The fact that there are debug messages in there certainly kinda suggests to me that it's not using your logback.xml file. Possibly because it's finding another one or possibly because it is finding another binding altogether.

You could try grepping your catalina.out for the string "slf4j" - if SLF finds multiple bindings it'll print a warning on the console when it first starts.

You could also try adding the following system property -Dlogback.debug=true to your startup args, this will cause logback to print debug details as it bootstraps.

.

Nothing in catalina.out for the string "slf". How should the system property be added to the startup args?

view this post on Zulip James Agnew (Dec 22 2020 at 17:27):

That I'm not sure, I haven't used Tomcat in a long time. I'm sure googling something like "Tomcat Set System Property" would have results though

view this post on Zulip Joel Schneider (Dec 22 2020 at 21:03):

The Tomcat 7.0 RUNNING.txt file mentions a "setenv" script, and environment variables such as CATALINA_OPTS and JAVA_OPTS.
https://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt

view this post on Zulip Fran del Río (Dec 30 2020 at 19:49):

Thanks James & Joel! My problem was next: my logback.xml file was in hapi-app/WEB-INF/ directory :-1: instead of hapi-app/WEB-INF/classes/ directory :+1: . For this reason, all the configuration that was carried out in it was ignored.

I just moved it to the right one. Now it's considering the configured appenders, loggers, etc.

Thanks again and happy new year!


Last updated: Apr 12 2022 at 19:14 UTC