--------------------------------------------------------------------------
Document:  Syslog4j Examples
Version:   $Id: examples.html,v 1.7 2009/07/25 18:43:22 cvs Exp $
URL:       http://www.syslog4j.org/
--------------------------------------------------------------------------
// Direct
Syslog.getInstance("udp").info("Log Message");
--------------------------------------------------------------------------
// Instance
SyslogIF syslog = Syslog.getInstance("tcp");
syslog.warn("Log Message");
--------------------------------------------------------------------------
// Set a Specific Host, then Log to It
SyslogIF syslog = Syslog.getInstance("udp");
syslog.getConfig().setHost("192.168.100.1");
syslog.getConfig().setPort(1514);
syslog.fatal("Log Message");
--------------------------------------------------------------------------
// Checksum
Syslog.getInstance("udp").getConfig().addMessageModifier(ChecksumSyslogMessageModifier.CRC32);
Syslog.getInstance("udp").info("Checksum'd message");
--------------------------------------------------------------------------
// Sequence
Syslog.getInstance("udp").getConfig().addMessageModifier(SequentialSyslogMessageModifier.DEFAULT);
Syslog.getInstance("udp").info("Message with a serial number appended");
--------------------------------------------------------------------------
// SHA256 Hash
Syslog.getInstance("udp").getConfig().addMessageModifier(HashSyslogMessageModifier.SHA256);
Syslog.getInstance("udp").info("Hash'd message");
--------------------------------------------------------------------------
// Custom Syslog Implementation (Design your own!)
SyslogConfigIF config = new MyVeryOwnCustomUdpSyslogConfig();
Syslog.createInstance("customUdp",config);

// Use Your Custom Syslog Implementation
Syslog.getInstance("customUdp").info("Log Message");
--------------------------------------------------------------------------
// Create a PCISyslogMessage
PCISyslogMessage message =
  new PCISyslogMessage("appId","jsmith","login","success","jsmith");

// Log the PCISyslogMessage
Syslog.getInstance("udp").info(message);
--------------------------------------------------------------------------
// Pooled TCP syslog
SyslogConfigIF config = new PooledTCPNetSyslogConfig();
Syslog.createInstance("pooledTcp",config);

// Log the Pooled syslog Message
Syslog.getInstance("pooledTcp").info("Pooled Test Log Message");
--------------------------------------------------------------------------
// TCP over SSL (secure) syslog
SyslogConfigIF config = new SSLTCPNetSyslogConfig();
Syslog.createInstance("sslTcp",config);

// Log the Secured syslog Message
Syslog.getInstance("sslTcp").info("Test SSL Log Message");
--------------------------------------------------------------------------
// Pooled TCP over SSL (secure) syslog
SyslogConfigIF config = new PooledSSLTCPNetSyslogConfig();
Syslog.createInstance("pooledSslTcp",config);

// Log the Secured syslog Message
Syslog.getInstance("pooledSslTcp").info("Pooled Test SSL Log Message");
--------------------------------------------------------------------------
// Send to Multiple syslog protocols At Once
MultipleSyslogConfig config = new MultipleSyslogConfig();
config.addProtocol("tcp");
config.addProtocol("udp");

Syslog.createInstance("multiple",config);

SyslogIF syslog = Syslog.getInstance("multiple");
syslog.info("Multiple Test Log Message");
--------------------------------------------------------------------------
// Structured Syslog - using a StructuredSyslogMessage instance

SyslogIF syslog = Syslog.getInstance("udp");
		
Map mInner = new HashMap();
mInner.put("innerName","innerValue");
		
Map mOuter = new HashMap();
mOuter.put("outerName",mInner);
		
StructuredSyslogMessage message = new StructuredSyslogMessage(
  "messageId",mOuter,"Test Structured Message"
);

syslog.info(message);
--------------------------------------------------------------------------
// Structured Syslog - set for all logging to "udp" protocol

SyslogIF syslog = Syslog.getInstance("udp");
syslog.getConfig().setUseStructuredData(true);

// Because of the above configuration change, the following String will
// be constructed into a StructuredSyslogMessage instance using a
// null messageId and structuredData parameters
syslog.info("Structured Test Log Message");
--------------------------------------------------------------------------