LrJposChannel.setLogger

Sets the logger for the channel.

public static void setLogger(Logger logger, String realm)

Parameters

ParameterDescription
loggerThe org.jpos.util.Logger instance to associate with the channel.
realmString that represents an identifier for the packager.

General information

Pack/unpack exceptions are displayed as <realm>: <exception message>. The realm can change over time, but the first realm (set by default by the jPOS library) is always remembered.

For details, see LrJposChannel.getOriginalRealm.

Return values

This function does not return any values.

Example

Copy code
public void binary2003_logger() throws Throwable{

        //system.out logger
        Logger consoleLogger = new Logger();
        consoleLogger.addListener(new SimpleLogListener(System.out));
        
        //adding logger to the channel
        LrJposChannel.setLogger(consoleLogger, "consoleLogger");
        
        lr.output_message("Realm: " + LrJposChannel.getRealm());
        lr.output_message("OriginalRealm: " + LrJposChannel.getOriginalRealm());
       
        //read message from file
        LrISOMsg msg= new LrISOMsg();
        msg.setPackager(new XMLPackager());
        InputStream stream = new FileInputStream("message1.xml");
        msg.unpack(stream);
        
        for (int i=1; i<8; i++) {
            msg.set(11, createMessageTrace(i));
            LrJposChannel.send(msg);
        }
        
        //add loggs to file:
        //received message should be logged on console and in specified file
        PrintStream output = new PrintStream("ISOLogFile.log");
        Logger logger = LrJposChannel.getLogger();
        logger.addListener(new SimpleLogListener(output));
        
        LrISOMsg r = new LrISOMsg();
        while (r != null) {
            r = LrJposChannel.receive(5);
        }
}