Enabling single-user logging
About this task
You can enable single-user logging by configuring logging to use the XML file and then editing the XML file.
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 Unica Platform is configured in a cluster deployment, copy the XML file to each node.
- You can enable single-user logging by editing the XML file.
- Logging is configured using log4j.xml, which is the default configuration file.
- If Unica Platform is configured in a cluster deployment, copy the XML file to each node.
- 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 Unica Platform is configured in a cluster deployment, set this JVM parameter in each node of the cluster.
- 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.
- 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.
- If Unica 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 thelog4j.xml
file. You can use any name for the copied file. Log file is also created with this new name like log4j_node1.log automatically instead of default name platform.log.Consider the following example where the logs are collected for the user asm_admin and 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> <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> </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>
Procedure
-
To specify the user account to be logged in per-user logging, edit the
log4j.xml
file and uncomment RollingFile tag with name UserLogAppender. Add the userid in the filter tag. The logs for the user that is added in the filter tag are saved in the file that is mentioned in that appender. Set below JVM parameter if not already set,-DUNICA_PLATFORM_HOME= <platform_home_directory_path>
- 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.
-
If Unica 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 thelog4j.xml
file. You can use any name for the copied file. Log file is also created with this new name like log4j_node1.log automatically instead of default name platform.log.
Example
asm_admin
and for all other
users.<?xml version="1.0" encoding="UTF-8"?>
<Configuration packages="com.unica.manager.logger" monitorInterval="60">
<Appenders>
<!-- Console Log Appender ->
<Console name="CONSOLE_LOG" target="SYSTEM_OUT" immediateFlush="true">
<PatternLayout pattern="%-5p %c - %m%n"/>
</Console>
<!-- System Log Appender -->
<!-- The following section is for logs for all the user-->
<RollingFile name="SYS_LOG" fileName="${sys:UNICA_PLATFORM_LOG_FILE}"
filePattern="${sys:UNICA_PLATFORM_LOG_FILE}.%d{yyyy-MM-dd}-%i"
immediateFlush="true" append="true" >
<PatternLayout pattern="%d{DATE} - %-5p - %m%n" />
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<SizeBasedTriggeringPolicy size="10 MB" />
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
<!-- The following section is for user specific logs for the user asm_admin-->
<RollingFile name="UserLogAppender" fileName="${sys:UNICA_PLATFORM_HOME}/logs/asm_admin.log"
filePattern="${sys:UNICA_PLATFORM_HOME}/logs/asm_admin.log.%d{yyyy-MM-dd}"
immediateFlush="true" 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>
</Appenders>
<Loggers>
<Root level="WARN" includeLocation="true">
<AppenderRef ref="SYS_LOG"/>
<AppenderRef ref="CONSOLE_LOG"/>
<!-- <AppenderRef ref="UserLogAppender"/> -->
</Root>
<!-- <Logger name="com.unicacorp" level="INFO"> -->
<!-- <AppenderRef ref="UserLogAppender"/> -->
<!-- </Logger> -->
<!-- <Logger name="com.unica" level="INFO"> -->
<!-- <AppenderRef ref="UserLogAppender"/> -->
<!-- </Logger> -->
</Loggers>
</Configuration>