Joke Collection Website - Blessing messages - What database is suitable for sending SMS logs?
What database is suitable for sending SMS logs?
The system must use LOG4J for log management, otherwise this method is invalid.
The system must contain two JAR packages, commons-logging-xxx.jar and log4j-xxx.jar, where xxx is the version number.
Second, the operation steps
1, create a log table.
In order to make the log persistent, a table must be created in the database to store the log information, and the field in the table is log.
One of the main properties of includes: operation class, execution method, printing time, log level and log content.
CREATE TABLE RES log(LOGID varchar 2(20)NOT NULL,
VARCHAR2 class (200),
Methods VARCHAR2( 100),
Date and time of creation,
LOGLEVEL VARCHAR2(50),
MSG VARCHAR2(4000))
Because the stored class is the full path of the class, the length of the class field needs to be large.
2. Log management configuration
LOG4J mainly has two configuration files. Attributes and. Xml, which is based on the property file here.
Above, regarding the configuration of XML files, I believe you can easily complete it after reading the following introduction.
Usually the first line in LOG4J. The properties file is:
Log4j.rootLogger= XXX, this sentence is the output of the control log. If you want to export logs to a database,
You need to add a funny DB to XXX, such as log4j. rootlogger = info,stdout,platform,db。 exceed
Output the information in the log to STDOUT, PLATFORM and DB.
(database).
After configuring the above information, LOG4J knew that the user wanted to save the information in the database, and then we came.
Configure information about the database (including cache, database connection information, SQL execution). The configuration information is as follows:
###JDBCAppender
log4j . appender . db = org . Apache . log4j . JDBC . JDBC appender
//This configuration chooses to use the JDBCAppender method to store log information in the database. Of course, if you want to do other operations, you can write your own class and inherit JDBCAppender.
log4j . appender . db . buffer size = 1
//This configuration tells LOG4J how many pieces of log information are stored in the database. I have 1 here, that is to say, if there is a piece, I will look it up. Obviously, this will greatly affect the system performance in the production environment.
log4j . appender . db . driver = Oracle . JDBC . driver . Oracle driver
//This configuration tells LOG4J to be the driver of database storage.
log4j . appender . db . URL = JDBC:Oracle:thin:@ & lt; Ip & gt:& lt port & gt:& ltsid & gt
//Needless to say, the URL of this configuration database connection is also known.
log4j.appender.db.user=XXX
log4j.appender.db.password=XXX
//The above two are the user name and password when connecting to the database.
Log4j. appender. db. SQL = Insert RESLOG
(LogId, class, method, creation time, log level, message)
Value (SQ_RESLOG_LOGID. Nextval,' %C ',' %M ',
To date ('%d{-MM-dd HH:mm:ss}',' -MM-dd.
HH24:mi:ss '),' %p ',' %m ')
//This configuration is the SQL statement used to tell LOG4J to record the database. SQ_RESLOG_LOGID。 Nextval is a sequence; I built; % c' is a class; In the log; "%m" is a method of printing logs and executing logs by class; "%d" is the printing time, which supports formatting. "%p" is the log level, including information, debugging, errors, etc. "%m" is the content of the log. Note that the parameters here are case-sensitive.
log4j . appender . db . layout = org . Apache . log4j . pattern layout
Through the above configuration, now start the service, and LOG4J will automatically store the original storage in. At the same time, log files are imported into the database.
- Related articles
- I want to ask a man who likes me to introduce me to my job. Can I make a phone call without meeting you?
- How to hack platform SMS?
- Who can tell me why the text message does not show the sender?
- Samsung a7 call in your pocket, take it out without sound.
- How about Guangzhou Jiuchuang Electronic Technology Co., Ltd.?
- Say hello to customers: Morning light is the theme of my greeting.
- Received a frozen SMS from Alipay.
- How to send international text messages to Mexico?
- Five Essays on the Theme of "Fastening the First Button of Clean Politics"
- The college entrance examination registration dynamic password keeps failing