Jamf On Prem logging to stdout/console with log4j2.xml

New Contributor II

With the release of Jamf Pro 10.31.0 they updated the logging to be defined in xml format in the new log4j2.xml file. This allows for the standard xml logging format to be used. Documentation here

By default it will log out to the os specific default Jamf log folder using the rolling file appender you can see defined in the file multiple times.

        <SizeBasedTriggeringPolicy size="100MB"/>
        <Pattern>%d{DEFAULT} [%-5p] [%-11.11t] [%-25.25c{1}] - %m%n</Pattern>
    <DefaultRolloverStrategy max="10"/>


This file appender is configured to be the target of the Jamf root logger using the following logger definition

<Root level="info" includeLocation="false">
    <AppenderRef ref="JAMF"/>


What we can do to enable the console/stdout logging is by creating a new appender within the Appenders element with the console configuration which has a target of system.out. Like the following

<Console name="Console" target="SYSTEM_OUT">
    <PatternLayout pattern="%d{ISO8601} [%-5p] [%-11.11t] [%-25.25c{1}] - %msg%n"/>


Then this can be added to the Jamf root logger simply

<Root level="info" includeLocation="false">
    <AppenderRef ref="JAMF"/>
    <AppenderRef ref="Console"/>


This can be replicated for any of the other loggers to include or exclude certain subsets of the logging!


Contributor II

Do you have any idea what the `includeLocation` attribute does that appears throughout?