By default, the AppDynamics Java Agent writes log files to the <agent_home>/ver<version_number>/logs/<node_name> directory. 

See Agent Log Files for information about how the logs are organized into sets that rollover. 

Configure Appender Attributes

Each logger has one or more appenders. Each appender specifies where, and in what format, the data is logged. For each appender, you can configure these attributes:

AttributeDescriptionTypeDefault Value
fileNameThe name of the log file.String-
nameThe name of the appender.String-
directoryThe directory that the log file is saved to.String""
immediateFlushWhether or not to immediately flush log data. Options: true, false Stringtrue
bufferSizeThe size, in MB, of the event buffer. The buffer temporarily stores messages before they are written to disk.String256 KB

Configure Log File Sizes and Rollovers

You may want to limit the length of your agent log files to make troubleshooting easier. To do this, you can specify a maximum size for your log files. When a log reaches that size, it is then rolled over: the log file gets zipped, and a new blank log file is generated to store the next batch of log data. By default, a log file has a maximum size of 20 MB and can be rolled over four times. See Troubleshooting Java Agent Issues. 

You can configure log rollover attributes in the log4j2.xml file.

  1. In log4j2.xml, find the ADRRAFAppender element that you want to configure rollover attributes for.
  2. Modify the ADRolloverStrategy element and set values for these attributes:

    AttributeDescriptionType
    maxThe maximum number of log files. When the maximum number of files is reached, the oldest log file after the initial log file is deleted.String
    compressionLevelThe degree of file compression, with 0 being uncompressed and 9 being the most compressed.String
    formatThe file format that the log is saved in. Options: zip, gzString

    For example:

    <ADRRAFAppender name="BusinessTransactionsLogger" fileName="BusinessTransactions.log">
     <PatternLayout pattern="[%t] %d{DATE} %5p - %m%n" />
     <SizeBasedTriggeringPolicy size="20 MB" />
     <ADRolloverStrategy max="5", compressionLevel="8", format="zip" />
    </ADRRAFAppender>

    In the above example, "5" is the total number of log files with backups per appender type per set that we keep. In essence, each agent restart will create {number of appenders} files as a set. Then each file can grow up to "5" files total consisting of the first file and 4 backup log files before it rolls over.

  3. Modify the SizeBasedTriggeringPolicy element and set values for these attributes:

    AttributeDescriptionType
    sizeThe maximum log file size, in MB, before a log is rolled over. By default, the size is 20MB before the rollover, because the logs are compressed.String

Modify the Log Directory Location

To specify a different log directory, use this system property: 

-Dappdynamics.agent.logs.dir 

The default logging directory is <agent_home>/ver<version_number>/logs/<node_name>.

Set the Agent Log Level

The default logging level for most log files is INFO. Higher logging levels consume more disk space; you can change the logging level to warn or error to reduce the amount of logging. You can control the logging level for the Java Agent by changing the value of the "level value" parameter in the log4j2.xml file in the versioned logging configuration file directory: <agent_home>/<version_number>/conf/logging. A restart of the application or agent is not required when changing the agent log level. For example, to set the log level to DEBUG:

<!-- to control the logging level of the agent log files, use the level attribute below. value="all|trace|debug|info|warn|error"--> 
<AsyncLogger name="com.singularity" level="debug" additivity="false">
    <AppenderRef ref="Default"/>
    <AppenderRef ref="RESTAppender"/>
</AsyncLogger>

Direct Logging to Syslog

Instead of having the Java Agent write to the default log directory in the agent home directory, you can configure the agent to direct logging output to syslog. The agent supports syslog-based logging through log4j SyslogAppender.  

Configure the Agent to Send Logs to syslog

  1. Open this configuration file in the agent home to edit:
    <agent_home>/ver<version_number>/conf/logging/log4j2.xml

  2. Add this section to the configuration file:

    <Syslog name="SyslogAppender" facility="LOCAL1" host="localhost" port="514" protocol="TCP">
        <PatternLayout pattern="[%t] %d{DATE} %5p %c - %m%n"/>
    </Syslog>
  3. Configure the agent to redirect its logs to this appender. Find and replace this section of the file: 

    <!-- to control the logging level of the agent log files, use the level attribute below. value="all|trace|debug|info|warn|error"--> 
    <AsyncLogger name="com.singularity" level="info" additivity="false">
        <AppenderRef ref="Default"/>
        <AppenderRef ref="RESTAppender"/>
    </AsyncLogger>

    With the following:

    <!-- to control the logging level of the agent log files, use the level attribute below. value="all|trace|debug|info|warn|error"--> 
    <AsyncLogger name="com.singularity" level="info" additivity="false">
        <AppenderRef ref="SyslogAppender"/>
        <AppenderRef ref="RESTAppender"/>
    </AsyncLogger>