Supressing/Setting Log Level

827 views
Skip to first unread message

Greg Harabedian

unread,
Sep 27, 2017, 1:47:22 PM9/27/17
to HAPI FHIR
I am new to HAPI and I was wondering how I set the log level and/or just suppress warning messages.  For example, I may get a message like the following when my software runs:

[main] WARN ca.uhn.fhir.parser.LenientErrorHandler - Found incorrect type for element identifier - Expected ARRAY and found OBJECT

I'd like to supress these warnings if possible.

James Agnew

unread,
Sep 27, 2017, 5:29:28 PM9/27/17
to Greg Harabedian, HAPI FHIR
Hi Greg,

You can find information how how logging works with HAPI here: http://hapifhir.io/doc_logging.html

You can basically configure logging in any way you want, including disabling specific loggers like the one you reference above.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/415c78ae-cfbc-4042-9c5f-7e544b623696%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Malcolm McRoberts

unread,
Sep 28, 2017, 5:10:44 PM9/28/17
to HAPI FHIR
Yes, I read this page, but still am not clear on how to change the log level for a specific class.  I want to  suppress all those INFO messages from the SearchBullder.  This looks like the way to do it, but not sure it's working.
logback.xml
<configuration scan="true" scanPeriod="30 seconds">

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} [%file:%line] %msg%n</pattern>
        </encoder>
    </appender>
        <logger name="ca.uhn.fhir.jpa.dao.SearchBuilder" level="DEBUG" />
    <root level="INFO">
        <appender-ref ref="STDOUT" />
    </root>

</configuration>



On Wednesday, September 27, 2017 at 5:29:28 PM UTC-4, James Agnew wrote:
Hi Greg,

You can find information how how logging works with HAPI here: http://hapifhir.io/doc_logging.html

You can basically configure logging in any way you want, including disabling specific loggers like the one you reference above.

Cheers,
James
On Wed, Sep 27, 2017 at 1:47 PM, Greg Harabedian <greg.ha...@gmail.com> wrote:
I am new to HAPI and I was wondering how I set the log level and/or just suppress warning messages.  For example, I may get a message like the following when my software runs:

[main] WARN ca.uhn.fhir.parser.LenientErrorHandler - Found incorrect type for element identifier - Expected ARRAY and found OBJECT

I'd like to supress these warnings if possible.

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.

James Agnew

unread,
Sep 28, 2017, 8:14:45 PM9/28/17
to Malcolm McRoberts, HAPI FHIR
Hi Malcolm,

It may be worth having a read through logback's documentation to see all of the power that is in there. It's quite a neat library actually: https://logback.qos.ch/manual/configuration.html

Specifically, if you want to suppress a specific logger and prevent it from showing up elsewhere, you would just need to declare the logger with no appenders and no additivity:

<logger name="ca.uhn.fhir.jpa.dao.SearchBuilder" level="ERROR" additivity="false" />

Cheers,
James

To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

Greg Harabedian

unread,
Oct 10, 2017, 2:43:45 PM10/10/17
to HAPI FHIR
Looked there but it doesn't really tell you how to disable logging.  As far as logging libraries, I only have the slf4j-api and slf4j-simple libraries installed.  Any additional detailed information on how to disable or set the the log level would be appreciated.  It seems like you can't explicitly set a log level in slf4j.  However, this seems like the only log library I have installed.
Greg


On Wednesday, September 27, 2017 at 2:29:28 PM UTC-7, James Agnew wrote:
Hi Greg,

You can find information how how logging works with HAPI here: http://hapifhir.io/doc_logging.html

You can basically configure logging in any way you want, including disabling specific loggers like the one you reference above.

Cheers,
James
On Wed, Sep 27, 2017 at 1:47 PM, Greg Harabedian <greg.ha...@gmail.com> wrote:
I am new to HAPI and I was wondering how I set the log level and/or just suppress warning messages.  For example, I may get a message like the following when my software runs:

[main] WARN ca.uhn.fhir.parser.LenientErrorHandler - Found incorrect type for element identifier - Expected ARRAY and found OBJECT

I'd like to supress these warnings if possible.

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.

James Agnew

unread,
Oct 10, 2017, 2:47:26 PM10/10/17
to Greg Harabedian, HAPI FHIR
If you remove the slf4j-simple JAR, and add logback-classic.jar instead, you can include a logback.xml file which configures the output. Here's a fairly complex example of such a file, which has different outputs for different loggers: https://github.com/jamesagnew/hapi-fhir/blob/master/hapi-fhir-jpaserver-uhnfhirtest/src/main/resources/logback.xml

Cheers,
James

To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

Greg Harabedian

unread,
Oct 10, 2017, 2:57:59 PM10/10/17
to HAPI FHIR
When I enable debug mode and execute the line:

FhirContext context = FhirContext.forDstu3();
where I had previously imported ca.uhn.fhir.context.FhirContext,
I get the console message:

[main] INFO ca.uhn.fhir.util.VersionUtil - HAPI FHIR version is: 2.5
[main] INFO ca.uhn.fhir.context.FhirContext - Creating new FHIR context for FHIR version [DSTU3]

The question is how do I supress this?
Greg

James Agnew

unread,
Oct 10, 2017, 4:18:44 PM10/10/17
to Greg Harabedian, HAPI FHIR
If you set those loggers (or just the root logger) to a level higher than INFO (WARN or ERROR) in your logback.xml, you won't see INFO level messages such as those ones.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.

Fran / Carl

unread,
Dec 22, 2020, 7:59:02 AM12/22/20
to HAPI FHIR
Hi!  I have same problem, I don't know how to supress this kind of log messages:

12:48:05.656 [ajp-nio-127.0.0.1-8009-exec-1]  DEBUG  ca.uhn.fhir.context.ModelScanner - Scanning datatype class: org.hl7.fhir.r4.model.UsageContext
12:48:05.656 [ajp-nio-127.0.0.1-8009-exec-1]  DEBUG  ca.uhn.fhir.context.ModelScanner - Scanning datatype class: org.hl7.fhir.r4.model.Reference
12:48:05.659 [ajp-nio-127.0.0.1-8009-exec-1]  DEBUG  ca.uhn.fhir.context.ModelScanner - Scanning resource class: org.hl7.fhir.r4.model.MarkdownType

How can I supress this?  I'm attaching my logback.xml and catalina.out file.   What I'm doing wrong?

Thanks in advance.


El martes, 10 de octubre de 2017 a la(s) 17:18:44 UTC-3, james...@gmail.com escribió:
If you set those loggers (or just the root logger) to a level higher than INFO (WARN or ERROR) in your logback.xml, you won't see INFO level messages such as those ones.

Cheers,
James

On Tue, Oct 10, 2017 at 2:57 PM, Greg Harabedian <greg.ha...@gmail.com> wrote:
When I enable debug mode and execute the line:

FhirContext context = FhirContext.forDstu3();
where I had previously imported ca.uhn.fhir.context.FhirContext,
I get the console message:

[main] INFO ca.uhn.fhir.util.VersionUtil - HAPI FHIR version is: 2.5
[main] INFO ca.uhn.fhir.context.FhirContext - Creating new FHIR context for FHIR version [DSTU3]

The question is how do I supress this?
Greg

On Wednesday, September 27, 2017 at 10:47:22 AM UTC-7, Greg Harabedian wrote:
I am new to HAPI and I was wondering how I set the log level and/or just suppress warning messages.  For example, I may get a message like the following when my software runs:

[main] WARN ca.uhn.fhir.parser.LenientErrorHandler - Found incorrect type for element identifier - Expected ARRAY and found OBJECT

I'd like to supress these warnings if possible.

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.
logback.txt
catalina.txt

Fran / Carl

unread,
Dec 30, 2020, 2:45:50 PM12/30/20
to HAPI FHIR
Sharing my problem and solution:  in my case,   logback.xml  file was in hapi-app/WEB-INF/  directory  instead of  hapi-app/WEB-INF/classes/  directory.  For this reason, all the configuration that was carried out in it was ignored. I just moved it to the right one directory. 

Now it's considering the configured appenders, loggers, etc.

Reply all
Reply to author
Forward
0 new messages