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

Yohan
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.

<RollingFile
        name="JAMF"
        fileName="/Library/JSS/Logs/JAMFSoftwareServer.log"
        filePattern="/Library/JSS/Logs/JAMFSoftwareServer.log.%i">
    <Policies>
        <SizeBasedTriggeringPolicy size="100MB"/>
    </Policies>
    <PatternLayout>
        <Pattern>%d{DEFAULT} [%-5p] [%-11.11t] [%-25.25c{1}] - %m%n</Pattern>
    </PatternLayout>
    <DefaultRolloverStrategy max="10"/>
</RollingFile>

 

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"/>
</Root>

 

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"/>
</Console>

 

Then this can be added to the Jamf root logger simply

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

 

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

1 REPLY 1

prbsparx
Contributor II

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