Enabling single-user logging

You can enable single-user logging by configuring logging to use the XML file and then editing the XML file.

About this task

Logging is configured using one of two files: log4j.properties or log4j.xml. By default, the log4j.properties file is used.

You can enable per-user logging by configuring logging to use the XML file and then editing the XML file. If Marketing Platform is configured in a cluster deployment, copy the XML file to each node.

Note: With XML logging enabled, a thread is created that periodically checks if the XML configuration file has been created or modified. If a change or file creation is detected, then the XML file is read to configure log4j. The polling interval is 60 seconds.

Procedure

  1. Configure logging to use log4j.xml by setting the following JVM parameter.

    -DENABLE_PLATFORM_LOG4J_XML_LOGGING=true

    The value must be set to true to enable per-user logging.

    If Marketing Platform is configured in a cluster deployment, set this JVM parameter in each node of the cluster.

  2. To specify the user account to be logged in per-user logging, edit the log4j.xml file and add the users in the filter tag. The logs for the users that are added in the filter tag are saved in the file that is mentioned. You can also create an appender without the filter tag.
    • You can add multiple tags in the log4j.xml file to create separate log files for specific users. You must add a new appender for each new user specific log file.
    • By default, the log file is created in the Platform_Home /Platform/logs folder and is named as platform.log. You can specify a different valid path and file name. You must specify the absolute or complete path to generate the log files in the respective folders.
    • If both user specific logs and logs for all users are required, add an appender tag with a new name and without the filter tag defined. The appender must have a unique name.
    • Add a corresponding entry under the root tag for this new appender.
  3. If Marketing Platform is configured in a cluster deployment, copy the edited XML file to each node of the cluster.

    You can use a command like the one shown in the following example.

    -DPLATFORM_LOG4J_XML_FILE=log4j_node1.xml

    The log4j_node1.xml file is a copy of the log4j.xml file. You can use any name for the copied file.

Example

Consider the following example where the logs are collected for the user asm_admin and also for all other users.
<appender name="Console" class="org.apache.log4j.ConsoleAppender">
  <param name="ImmediateFlush" value="true"/>
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%-5p %c - %m%n"/>
  </layout>
  <filter class="com.unica.manager.logger.UserMatchFilter">
    <param name="StringToMatch" value="asm_admin" />
  </filter>
</appender>

<!-- The following section is for user specific logs for the user asm_admin -->
<appender name="System" class="org.apache.log4j.RollingFileAppender">
  <param name="File" value="${UNICA_PLATFORM_LOG_FILE}"/> 
  <!-- <param name="Encoding" value="utf-8"/>
  <param name="Append" value="true"/>
  <param name="ImmediateFlush" value="false"/>
  -->
  <param name="MaxBackupIndex" value="1"/>
  <param name="MaxFileSize" value="10MB"/>
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{DATE} - %-5p - %m%n"/>
  </layout>
  <filter class="com.unica.manager.logger.UserMatchFilter">
    <param name="StringToMatch" value="asm_admin" />
  </filter>
</appender>

<!-- The following section is for logs for all the users -->
<appender name="SystemAllUsers" class="org.apache.log4j.RollingFileAppender">
  <param name="File" value="<LOG_FILE_PATH>"/><!--the absolute path for the log file-->
  <!-- <param name="Encoding" value="utf-8"/>
  <param name="Append" value="true"/>
  <param name="ImmediateFlush" value="false"/>
  -->
  <param name="MaxBackupIndex" value="1"/>
  <param name="MaxFileSize" value="10MB"/>
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{DATE} - %-5p - %m%n"/>
  </layout>
</appender>

<!-- <logger name="com.unica.manager.configuration.ConfigurationManager">
    <level value="TRACE"/>
  </logger>
  <logger name="com.unica.suite.scheduler.server.manager.TaskManager">
    <level value="DEBUG"/>
  </logger>
  <logger name="org.hibernate.util.JDBCExceptionReporter">
    <level value="ERROR"/>
  </logger>
-->
<root>
  <level value="WARN"/>
    <appender-ref ref="System"/>
    <appender-ref ref="Console"/>
    <appender-ref ref="SystemAllUsers"/>		
</root>