Modify the log4j files

You can set up the rotation of several log files based on the file size by editing the files listed under Log4j files.

Configure Log rotation to a file per file-size

In this example, the configuration file is the TM log: <FILEDRIVEHOME>/conf/tm-log4j.xml. The example uses FILEDRIVEHOME instead of <FILEDRIVEHOME> to represent the SecureTransport installation directory to avoid confusion with the syntactic use of pointed brackets in XML.

Change:

<appender name="ServerLog" class="com.tumbleweed.st.server.logging.DailyRollingFileAppender">

  <param name="File" value="FILEDRIVEHOME/STServer/var/logs/tm.log" />

  <param name="Append" value="true" />

  <param name="RotateDirectory" value="FILEDRIVEHOME/STServer/var/db/hist/logs" />

  <layout class="org.apache.log4j.PatternLayout">

    <param name="ConversionPattern" value="%d %p [%t] %c - %m%n" />

  </layout>

</appender>

To:

<appender name="ServerLog" class="org.apache.log4j.RollingFileAppender">

  <param name="File" value="FILEDRIVEHOME/STServer/var/logs/tm.log" />

  <param name="MaxFileSize" value="10485760" />

  <param name="Append" value="true" />

  <param name="DatePattern" value="'.'yyyy-MM-dd" />

  <param name="MaxBackupIndex" value="5" />

  <layout class="org.apache.log4j.PatternLayout">

      <param name="ConversionPattern" value="%d %p [%t] %c - %m%n" />

  </layout>

</appender>

 

You can use any of the log4j file appenders. com.tumbleweed.st.server.logging.DailyRollingFileAppender supports the RotateDirectory parameter. If you use the Apache RollingFileAppender, the file rotates into the same directory as the original file with a ".n" suffix appended to the filename, where "n" is an integer number up to the MaxBackupIndex value. You need to use another method to move the backup log files from <FILEDRIVEHOME>/var/logs.

Note For another way to manage log file rotation, see Create a Log Entry Maintenance application.

Attach logger to a non-blocking asynchronous appender

In some cases when the log messages are directed to a flat file, the rotation of the file might take a considerable amount of time during which certain SecureTransport processes (including user log-in) are unavailable. This might happen, for example, when rotating a large log to a file which is hosted on a remote location.

In this case, you might consider attaching the rotating log to an asynchronous appender which is explicitly defined as not-blocking. To achieve this, use the following example:

<appender name="ServerLog" class="org.apache.log4j.AsyncAppender">

  <param name="BufferSize" value="20000" />

  <param name="blocking" value="false" />

  <param name="LocationInfo" value="false"/>

  <appender-ref ref="AsyncAppender" />

</appender>

<appender class="com.tumbleweed.st.server.logging.DailyRollingFileAppender" name="AsyncAppender">

  <param name="File" value="/opt/mysql54/Axway/SecureTransport/var/logs/tm.log" />

  <param name="Append" value="true" />

  <param name="DatePattern" value="'.'yyyy-MM-dd" />

  <param name="RotateDirectory" value="/mnt/logs/" />

  <layout class="org.apache.log4j.PatternLayout">

  <param name="ConversionPattern" value="%d %p [%t] %c - %m%n" />

  </layout>

</appender>

Related topics:

Related Links