Configuring system logs

To log configuration, debugging, and error information, Unica Plan uses the Apache log4j utility. To change the types of messages that this utility includes in the system log, you must change the value of the level property in the plan_log4j.xml file placed in the <Plan_Home>/conf/ location. The plan_log4j.xml file is referenced in the JVM system properites by the -Dlog4j2.configurationFile and -Dlog4.configurationFile. If you are using an XML file other than plan_log4j.xml in the properties -Dlog4j2.configurationFile and -Dlog4.configurationFile, then you must use the same file, instead of using the plan_log4j.xml file, for the earlier mentioned purpose

Setting the logging level

You can set the logging level to FATAL, ERROR, WARN, INFO, or DEBUG to capture an increasing number of messages. For example, to record the maximum number of messages to help troubleshoot a problem, you scroll to the end of the plan_log4j.xml file and change the level to DEBUG:

<Root level="DEBUG" includeLocation="true">
      <AppenderRef ref="SYS_LOG"/>
</Root>

When your investigation is complete, you change the level value back to the default, WARN:

<Root level="WARN" includeLocation="true">
   <AppenderRef ref="SYS_LOG"/>
</Root>
Tip: The plan_log4j.xml file is reloaded 60 seconds after it is updated, so a server restart is not necessary after you edit this file.

Creating a back up of a log file

You can create a back up of a log file after it reaches a certain size by using the size based trigger policy. A back up file is created when the log file reaches the size mentioned in SizeBasedTriggeringPolicy. The value of max attribute in DefaultRolloverStrategy is the maximum number of back up files that can be created for a log file.

Consider the following example for creating a back up for the system.log file.


<RollingFile  name="SYS_LOG" fileName="${sys:plan.home}/logs/system.log"
	filePattern="${sys:plan.home}/logs/system.log.%d{yyyy-MM-dd}.%i.log.gz"
	immediateFlush="false" append="true" >
		<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%X\{user}] %-5p %F.%M:%L: %m%n" />
		<Policies>
			<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
			<SizeBasedTriggeringPolicy size="10 MB" />
		</Policies>
		<DefaultRolloverStrategy max="10"/>
		<UALevelMatchFilter levelToMatch="DEBUG, WARN,INFO, ERROR, FATAL" onMatch="ACCEPT" onMismatch="DENY"/>
</RollingFile>
Note: If you copy the above example and use it as is, you must comment the default System Log Appender in the plan_log4j.xml file.

Enabling debugging for specific functionalities

Use the preset modules in plan_log4j.xml, such as PROJECT, TASK, APPROVAL, and so on, to enable debugging for specific functionalities.

To debug specific modules, add the following loggers in the plan_log4j.xml file and uncomment the relevant sections.


	<!-- ============================================================== -->
	<!-- To debug specific module(s), uncomment the following logger(s) -->
	<!-- ============================================================== -->

	<!--  Functionality: PROJECT -->
	<!--
	<Logger name="com.unicacorp.uap.project" level="DEBUG"/>
	-->
	<!--  Functionality: PROGRAM -->
	<!--
	<Logger name="com.unicacorp.uap.program" level="DEBUG"/>
	-->
	<!--  Functionality: PLAN -->
	<!--            
	<Logger name="com.unicacorp.uap.plan" level="DEBUG"/>
	-->
	<!--  Functionality: TASK -->
	<!--
	<Logger name="com.unicacorp.uap.task" level="DEBUG"/>
	-->
	<!--  Functionality: CALENDAR -->
	<!--
	<Logger name="com.unicacorp.uap.calendar" level="DEBUG"/>
	-->
	<!--  Functionality: TEAM -->
	<!--            
	<Logger name="com.unicacorp.uap.team" level="DEBUG"/>
	-->
	<!--  Functionality: ASSET -->
	<!--            
	<Logger name="com.unicacorp.uap.assets" level="DEBUG"/>
	-->
	<!--  Functionality: APPROVAL -->
	<!--
	<Logger name="com.unicacorp.uap.approval" level="DEBUG"/>
	-->
	<!--  Functionality: ACCOUNT -->
	<!--
	<Logger name="com.unicacorp.uap.account" level="DEBUG"/>
	-->
	<!--  Functionality: INVOICE -->
	<!--            
	<Logger name="com.unicacorp.uap.invoice" level="DEBUG"/>
	-->
	<!--  Functionality: FORM EDITOR -->
	<!--            
	<Logger name="com.unicacorp.uap.formeditor" level="DEBUG"/>
	-->
	<!--  Functionality: GRID -->
	<!--            
	<Logger name="com.unica.grid" level="DEBUG"/>
	<Logger name="com.unicacorp.uap.grid" level="DEBUG"/>
	<Logger name="com.unicacorp.uap.tvc.grid" level="DEBUG"/>
	-->
	<!--  Functionality: TEMPLATE -->
	<!--            
	<Logger name="com.unicacorp.uap.common.template" level="DEBUG"/>
	-->
	<!--  Functionality: NOTIFICATION -->
	<!--            
	<Logger name="com.unicacorp.uap.notification" level="DEBUG"/>
	-->
	<!--  Functionality: OFFER -->
	<!--            
	<Logger name="com.unicacorp.uap.offer" level="DEBUG"/>
	-->
	<!--  Functionality: MARKETING OBJECT -->

	<!-- <Logger name="com.unica.uap.component" level="DEBUG"/> -->

Generating SQL logs

You can generate SQL logs when the root logging level is set to DEBUG.

Important: When you upgrade to Fix Pack 10.0.0.2, the plan_log4j.xml file is not overwritten. After you install Fix Pack 10.0.0.2, if you want to disable the generation of SQL logs, you must comment the SQL_LOG section. Otherwise, SQL logs will be generated after the upgrade.

	<!-- ================ -->
	<!-- SQL Log Appender -->
	<!-- ================ -->
	<!-- uncomment the section below for obtaining sql logs -->
	<!-- 
	<RollingFile  name="SQL_LOG" fileName="${sys:plan.home}/logs/sql.log" 
						filePattern="${sys:plan.home}/logs/sql.log.%d{yyyy-MM-dd}" 
						immediateFlush="false" append="true" >

						<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%X\{user}] %-5p %F.%M:%L: %m%n" />
						<Policies>
											<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
						</Policies>
						<UALevelMatchFilter levelToMatch="SQL" onMatch="ACCEPT" onMismatch="DENY"/>
	</RollingFile> 
	-->

Obtaining logs for a specific user in a specific log file

You can obtain logs for a specific user in a specific log file by using the class com.unica.afc.logger.UserMatchFilter.

To generate logs for a specific user, you must add and uncomment the following section in the plan_log4j.xml file and add the required information for the specific user.

The following example creates a log file asm_admin.log, for the user asm_admin.


<!-- ================================================================ -->
<!-- To obtain log file(s) by user, uncomment the following logger(s) -->
<!-- Below is an example to obtain a log file (asm_admin.log) for the -->
<!-- 'asm_admin' user.                                                                                                                                                                                                                                            -->
<!-- ================================================================ -->
<!--
	<RollingFile  name="UserLogAppender" fileName="${sys:plan.home}/logs/asm_admin.log"
		filePattern="${sys:plan.home}/logs/asm_admin.log.%d{yyyy-MM-dd}"
		immediateFlush="false" append="true" >
		<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%X\{user}] %-5p %F.%M:%L: %m%n" />
		<Policies>
			<SizeBasedTriggeringPolicy size="10 MB" />
		</Policies>
		<DefaultRolloverStrategy max="10"/>
		<UserMatchFilter user="asm_admin" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
	</RollingFile>
-->
 
<!--
	<Logger name="com.unicacorp" level="DEBUG">
		<AppenderRef ref="UserLogAppender"/>
	</Logger>
				   
	<Logger name="com.unica" level="DEBUG">
		<AppenderRef ref="UserLogAppender"/>
	</Logger>
-->

Additional logging capability to determine slow SQL queries

From version 12.1.4, Unica Plan has two system properties (jvm arguments) to determine the slow SQL queries as a part of troubleshooting performance issues:

  • -Dplan.slow.query.threshold=<value in milliseconds>

    If the value is greater than 0, all JDBC SQL queries, which take more time than the mentioned value, will appear in the logs.

  • -Dplan.slow.query.show.stack.trace=true

    If this parameter is true, java stack trace of slow SQL queries will appear in the logs.

Note: To enable this feature, ensure that you have enabled the debug logs of the application.

In the plan_log4j.xml file, available in the <plan_home>/conf/ location, add the following lines of code within the <Loggers> .... </Loggers> section and below the <Root> logger section:

Note: Alternatively, you can also add the following lines of code in the file configured with the -Dplan.log4j.config JVM parameter, if the file is different from plan_log4j.xml file.

<Logger name="com.unica.uap.common.diagnosticinfo" level="DEBUG" additivity="false" includeLocation="true">
	<AppenderRef ref="SYS_LOG"/>
</Logger>

Example:


<Loggers>
.
.
.
.
    <Root level="WARN" includeLocation="true">
        <AppenderRef ref="SYS_LOG"/>
    </Root>
    <Logger name="com.unica.uap.common.diagnosticinfo" level="DEBUG" additivity="false" includeLocation="true">
        <AppenderRef ref="SYS_LOG"/>
    </Logger> 
.
.
.
.
</Loggers>