Library: Net
Package: Logging
Header: Poco/Data/SQLChannel.h
This Channel implements logging to a SQL database. The channel is dependent on the schema. The DDL for table creation (subject to target DDL dialect dependent modifications) is:
"CREATE TABLE T_POCO_LOG (Source VARCHAR, Name VARCHAR, ProcessId INTEGER, Thread VARCHAR, ThreadId INTEGER, Priority INTEGER, Text VARCHAR, DateTime DATE)"
The table name is configurable through "table" property. Other than DateTime filed name used for optiona time-based archiving purposes, currently the field names are not mandated. However, it is recomended to use names as specified above.
To provide as non-intrusive operation as possbile, the log entries are cached and inserted into the target database asynchronously by default . The blocking, however, will occur before the next entry insertion with default timeout of 1 second. The default settings can be overriden (see async, timeout and throw properties for details). If throw property is false, insertion timeouts are ignored, otherwise a TimeoutException is thrown. To force insertion of every entry, set timeout to 0. This setting, however, introduces a risk of long blocking periods in case of remote server communication delays.
Direct Base Classes: Poco::Channel
All Base Classes: Poco::Channel, Poco::Configurable, Poco::RefCountedObject
Member Functions: close, getProperty, log, open, registerChannel, setProperty, wait
Inherited Functions: close, duplicate, getProperty, log, open, referenceCount, release, setProperty
SQLChannel();
Creates SQLChannel.
SQLChannel(
const std::string & connector,
const std::string & connect,
const std::string & name = "-"
);
Creates a SQLChannel with the given connector, connect string, timeout, table and name. The connector must be already registered.
~SQLChannel();
void close();
Closes the SQLChannel.
See also: Poco::Channel::close()
std::string getProperty(
const std::string & name
) const;
Returns the value of the property with the given name.
See also: Poco::Channel::getProperty()
void log(
const Message & msg
);
Sends the message's text to the syslog service.
See also: Poco::Channel::log()
void open();
Opens the SQLChannel.
See also: Poco::Channel::open()
static void registerChannel();
Registers the channel with the global LoggingFactory.
void setProperty(
const std::string & name,
const std::string & value
);
Sets the property with the given value.
The following properties are supported:
See also: Poco::Channel::setProperty()
std::size_t wait();
Waits for the completion of the previous operation and returns the result. If chanel is in synchronous mode, returns 0 immediately.
static const std::string PROP_ARCHIVE_TABLE;
static const std::string PROP_ASYNC;
static const std::string PROP_CONNECT;
static const std::string PROP_CONNECTOR;
static const std::string PROP_MAX_AGE;
static const std::string PROP_NAME;
static const std::string PROP_TABLE;
static const std::string PROP_THROW;
static const std::string PROP_TIMEOUT;