Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Process Logging with log4j

Level 1
Level 1

I'd like to use log4j to do some logging from processes. 

I've used the following executeScript to test this in a process:

import org.apache.log4j.*;

System.out.println("Log4jExecuteScriptTest: Start of log4j messages");

Logger logger = Logger.getLogger("com.fletch.Log4jTest");

logger.trace("Log4jExecuteScriptTest: This is a TRACE message");
logger.debug("Log4jExecuteScriptTest: This is a DEBUG message");"Log4jExecuteScriptTest: This is an INFO log message");
logger.warn("Log4jExecuteScriptTest: This is a WARN log message");
logger.error("Log4jExecuteScriptTest: This is an ERROR log message");

System.out.println("Log4jExecuteScriptTest: End of log4j messages");

SInce I'm doing this with the JBoss LC ES2.5 Turnkey I modified C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\conf\jboss-log4j.xml to add an appender and category for com.fletch.Log4jTest:

  <!-- A time/date based rolling appender for specifc log messages -->
   <appender name="Log4jTest_FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="File" value="${jboss.server.log.dir}/Log4jTest.log"/>
      <param name="Threshold" value="TRACE"/>
      <param name="Append" value="false"/>

      <!-- Rollover at midnight each day -->
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>

      <!-- Rollover at the top of each hour
      <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>

      <layout class="org.apache.log4j.PatternLayout">
         <!-- The default pattern: Date Priority [Category] Message\n -->
         <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>

         <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
         <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
<!-- Limit the com.fletch.Log4jTest category to TRACE for a test -->
   <category name="com.fletch.Log4jTest">
      <priority value="TRACE"/>
     <appender-ref ref="Log4jTest_FILE"/>

This way my log4j entries for com.fletch.Log4jTest end up in C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\log\Log4jTest.log:

2013-02-05 13:22:56,508 TRACE [com.fletch.Log4jTest] Log4jExecuteScriptTest: This is a TRACE message
2013-02-05 13:22:56,509 DEBUG [com.fletch.Log4jTest] Log4jExecuteScriptTest: This is a DEBUG message
2013-02-05 13:22:56,509 INFO  [com.fletch.Log4jTest] Log4jExecuteScriptTest: This is an INFO log message
2013-02-05 13:22:56,510 WARN  [com.fletch.Log4jTest] Log4jExecuteScriptTest: This is a WARN log message
2013-02-05 13:22:56,510 ERROR [com.fletch.Log4jTest] Log4jExecuteScriptTest: This is an ERROR log message

I'm thinking of building this as either a logging subprocess using executeScript or a Java component.  Which would be the preferred way to do this?

Any additional information on this would be appreciated.


Steve Fletcher

0 Replies