Here is source code:
-------------------------------
package log;
import java.io.*;
import org.jpos.iso.*;
import org.jpos.iso.packager.*;
import org.jpos.iso.channel.*;
import org.jpos.util.*;
import org.jpos.util.Logger;
public class RotateLog implements Runnable {
ISOChannel channel;
ISOMUX mux;
Logger logger;
public void setupLogger() {
// create a Logger object
logger = new Logger();
try {
// add a Simple listener that dumps log events to System.out
logger.addListener(new SimpleLogListener (System.out));
// add yet another Listener; this one will create
// files on your /tmp directory
logger.addListener(new RotateLogListener
("/tmp/jpos.log", 3600*1000, 5));
} catch (IOException e) {
e.printStackTrace();
}
}
public void setupMUX () {
ISOPackager p = new ISO87APackager();
// We want to log Packager events (there's no need to..)
// so we attach a Logger to the packager. We set an
// appropiate realm name (that should make sense
// to your application and a human operator)
p.setLogger (logger, "localhost.channel.packager");
//
// Create an ISOChannel. This one will connect
// to your ECHO service (you're using Unix, aren't you? :-)
//
channel = new ASCIIChannel ("localhost", 8000, p);
// assign a logger and an apropiate realm to your
// channel.
((LogSource)channel).setLogger (logger, "localhost.channel");
// create an ISOMUX with appropiate logger and realm
mux = new ISOMUX (channel);
mux.setLogger (logger, "localhost.mux");
// start your MUX
Thread t = new Thread (mux);
t.start();
}
public void run () {
// Send an ISORequest every 10 seconds
for (;;) {
ISOMsg m = new ISOMsg();
try {
m.set (new ISOField (0, "0800"));
m.set (new ISOField (11, "000001"));
m.set (new ISOField (41, "29110001"));
ISORequest rq = new ISORequest (m);
//
// New to this release is the fact that you
// can asign a Logger to your ISORequest. this
// will send a single log event with your
// request and it's response, as well as
// the elapsed time or an indication of
// expiration
//
rq.setLogger (logger, "isorequest");
mux.queue (rq);
ISOMsg r = rq.getResponse (10000);
Thread.sleep (10000);
} catch (ISOException e) {
} catch (InterruptedException e) { }
}
}
public static void main (String args[]) {
LogTest l = new LogTest();
l.setupLogger();
l.setupMUX ();
// Launch a SystemMonitor
new SystemMonitor (60000, l.logger, "monitor");
(new Thread(l)).start();
}
}
-------------------------------
Anyone please help me. Thank you very much.
--Alejandro
30383030303032303030303030303830303030303030303030313239313130303031
</pack>
</log>
<log realm="localhost.channel/127.0.0.1:8000" at="Wed Sep 27 08:37:09
ICT 2006.2
18">
<send>
<isomsg direction="outgoing">
<field id="0" value="0800"/>
<field id="11" value="000001"/>
<field id="41" value="29110001"/>
</isomsg>
</send>
</log>
<log realm="localhost.channel.packager" at="Wed Sep 27 08:37:09 ICT
2006.328">
<unpack>
30383030303032303030303030303830303030303030303030313239313130303031
<bitmap>{11, 41}</bitmap>
<unpack fld="11" packager="org.jpos.iso.IFA_NUMERIC">
<value>000001</value>
</unpack>
<unpack fld="41" packager="org.jpos.iso.IF_CHAR">
<value>29110001</value>
</unpack>
</unpack>
</log>
<log realm="localhost.channel/127.0.0.1:8000" at="Wed Sep 27 08:37:09
ICT 2006.4
53">
<receive>
<isomsg direction="incoming">
<field id="0" value="0800"/>
<field id="11" value="000001"/>
<field id="41" value="29110001"/>
</isomsg>
</receive>
</log>
<log realm="isorequest" at="Wed Sep 27 08:37:09 ICT 2006.562">
<ISORequest>
<request>
<isomsg direction="outgoing">
<field id="0" value="0800"/>
<field id="11" value="000001"/>
<field id="41" value="29110001"/>
</isomsg>
</request>
<response elapsed="984">
<isomsg direction="incoming">
<field id="0" value="0800"/>
<field id="11" value="000001"/>
<field id="41" value="29110001"/>
</isomsg>
</response>
</ISORequest>
</log>
---------------------------------------
where /temp/jpos.log file is autogenerated or is created manually?
Thank you very much.
Here
As I already mentioned (reason why you should actually read replies), you
have not created the path you are trying to save the log to, and if there is
something still not clear, then you should probably head to: