log4j Databse apender does not work properly
up vote
-1
down vote
favorite
My log4j.properties file look like
log4j.rootLogger = ERROR,sql, Appender1
log4j.logger.com.endeca=ERROR
log4j.logger.com.endeca.itl.web.metrics=ERROR
log4j.appender.sql=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.sql.URL=jdbc:mysql://192.168.70.39:3306/cortex_mcss_ip
log4j.appender.sql.driver=com.mysql.jdbc.Driver
log4j.appender.sql.user=root
log4j.appender.sql.password=123456
log4j.appender.sql.sql=INSERT INTO errorlog(Level,Msg,CreatedDate) VALUES ('%p','%m',now())
log4j.appender.sql.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1=org.apache.log4j.ConsoleAppender
log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
log4j.appender.Appender2=org.apache.log4j.FileAppender
log4j.appender.Appender2.File=D:/Logs/Log4jWebDemo.log
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
when error occurs it works fine on console and file appender,but does not insert into databse anything ?
Note : databse parameters are 100% accurate in every corner.
Any one please help me to solve this...plz...
java logging log4j
add a comment |
up vote
-1
down vote
favorite
My log4j.properties file look like
log4j.rootLogger = ERROR,sql, Appender1
log4j.logger.com.endeca=ERROR
log4j.logger.com.endeca.itl.web.metrics=ERROR
log4j.appender.sql=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.sql.URL=jdbc:mysql://192.168.70.39:3306/cortex_mcss_ip
log4j.appender.sql.driver=com.mysql.jdbc.Driver
log4j.appender.sql.user=root
log4j.appender.sql.password=123456
log4j.appender.sql.sql=INSERT INTO errorlog(Level,Msg,CreatedDate) VALUES ('%p','%m',now())
log4j.appender.sql.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1=org.apache.log4j.ConsoleAppender
log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
log4j.appender.Appender2=org.apache.log4j.FileAppender
log4j.appender.Appender2.File=D:/Logs/Log4jWebDemo.log
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
when error occurs it works fine on console and file appender,but does not insert into databse anything ?
Note : databse parameters are 100% accurate in every corner.
Any one please help me to solve this...plz...
java logging log4j
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
My log4j.properties file look like
log4j.rootLogger = ERROR,sql, Appender1
log4j.logger.com.endeca=ERROR
log4j.logger.com.endeca.itl.web.metrics=ERROR
log4j.appender.sql=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.sql.URL=jdbc:mysql://192.168.70.39:3306/cortex_mcss_ip
log4j.appender.sql.driver=com.mysql.jdbc.Driver
log4j.appender.sql.user=root
log4j.appender.sql.password=123456
log4j.appender.sql.sql=INSERT INTO errorlog(Level,Msg,CreatedDate) VALUES ('%p','%m',now())
log4j.appender.sql.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1=org.apache.log4j.ConsoleAppender
log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
log4j.appender.Appender2=org.apache.log4j.FileAppender
log4j.appender.Appender2.File=D:/Logs/Log4jWebDemo.log
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
when error occurs it works fine on console and file appender,but does not insert into databse anything ?
Note : databse parameters are 100% accurate in every corner.
Any one please help me to solve this...plz...
java logging log4j
My log4j.properties file look like
log4j.rootLogger = ERROR,sql, Appender1
log4j.logger.com.endeca=ERROR
log4j.logger.com.endeca.itl.web.metrics=ERROR
log4j.appender.sql=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.sql.URL=jdbc:mysql://192.168.70.39:3306/cortex_mcss_ip
log4j.appender.sql.driver=com.mysql.jdbc.Driver
log4j.appender.sql.user=root
log4j.appender.sql.password=123456
log4j.appender.sql.sql=INSERT INTO errorlog(Level,Msg,CreatedDate) VALUES ('%p','%m',now())
log4j.appender.sql.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1=org.apache.log4j.ConsoleAppender
log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
log4j.appender.Appender2=org.apache.log4j.FileAppender
log4j.appender.Appender2.File=D:/Logs/Log4jWebDemo.log
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
when error occurs it works fine on console and file appender,but does not insert into databse anything ?
Note : databse parameters are 100% accurate in every corner.
Any one please help me to solve this...plz...
java logging log4j
java logging log4j
asked Nov 8 at 4:52
rahuLrajaN
64
64
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
To Directly address your question:
you should debug this appender to see what happens.
Make sure that DB driver (mysql in this case) appears in the classpath of the application.
Make sure that the table / schema exist, because this appender by its own does not create a schema for you
Note that it has a "bufferSize" parameter, so only if the non-stored message count exceeds the buffer, the actual DB request gets performed.
Place a breakpoint on
org.apache.log4j.jdbc.JDBCAppender#execute
and see how it really executes
Overall observation/side notes, not directly related to your answer but still can be valuable.
This appender is really outdated and is not a really good solution for modern production applications (unless you have a very small number of logs).
This appender doesn't use batch inserts supported by probably all modern RDBMSs.
This appender doesn't user prepare statements.
All-in-all storing logs in RDBMS doesn't really make sense nowadays, logs are meant to be read and analyzed, and RDBMS doesn't offer really handy tools for this (both visual and from the maintenance standpoint: how do delete obsolete messages? Bulk DELETE is very expensive, partitioning? Retention Policies for records are not really supported in many RDBMSs...
So, a much more modern approach is using tools like ElasticSearch + Kibana (+ some log shipper) or even streaming logs to the cloud (like Logz.io)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
To Directly address your question:
you should debug this appender to see what happens.
Make sure that DB driver (mysql in this case) appears in the classpath of the application.
Make sure that the table / schema exist, because this appender by its own does not create a schema for you
Note that it has a "bufferSize" parameter, so only if the non-stored message count exceeds the buffer, the actual DB request gets performed.
Place a breakpoint on
org.apache.log4j.jdbc.JDBCAppender#execute
and see how it really executes
Overall observation/side notes, not directly related to your answer but still can be valuable.
This appender is really outdated and is not a really good solution for modern production applications (unless you have a very small number of logs).
This appender doesn't use batch inserts supported by probably all modern RDBMSs.
This appender doesn't user prepare statements.
All-in-all storing logs in RDBMS doesn't really make sense nowadays, logs are meant to be read and analyzed, and RDBMS doesn't offer really handy tools for this (both visual and from the maintenance standpoint: how do delete obsolete messages? Bulk DELETE is very expensive, partitioning? Retention Policies for records are not really supported in many RDBMSs...
So, a much more modern approach is using tools like ElasticSearch + Kibana (+ some log shipper) or even streaming logs to the cloud (like Logz.io)
add a comment |
up vote
0
down vote
accepted
To Directly address your question:
you should debug this appender to see what happens.
Make sure that DB driver (mysql in this case) appears in the classpath of the application.
Make sure that the table / schema exist, because this appender by its own does not create a schema for you
Note that it has a "bufferSize" parameter, so only if the non-stored message count exceeds the buffer, the actual DB request gets performed.
Place a breakpoint on
org.apache.log4j.jdbc.JDBCAppender#execute
and see how it really executes
Overall observation/side notes, not directly related to your answer but still can be valuable.
This appender is really outdated and is not a really good solution for modern production applications (unless you have a very small number of logs).
This appender doesn't use batch inserts supported by probably all modern RDBMSs.
This appender doesn't user prepare statements.
All-in-all storing logs in RDBMS doesn't really make sense nowadays, logs are meant to be read and analyzed, and RDBMS doesn't offer really handy tools for this (both visual and from the maintenance standpoint: how do delete obsolete messages? Bulk DELETE is very expensive, partitioning? Retention Policies for records are not really supported in many RDBMSs...
So, a much more modern approach is using tools like ElasticSearch + Kibana (+ some log shipper) or even streaming logs to the cloud (like Logz.io)
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
To Directly address your question:
you should debug this appender to see what happens.
Make sure that DB driver (mysql in this case) appears in the classpath of the application.
Make sure that the table / schema exist, because this appender by its own does not create a schema for you
Note that it has a "bufferSize" parameter, so only if the non-stored message count exceeds the buffer, the actual DB request gets performed.
Place a breakpoint on
org.apache.log4j.jdbc.JDBCAppender#execute
and see how it really executes
Overall observation/side notes, not directly related to your answer but still can be valuable.
This appender is really outdated and is not a really good solution for modern production applications (unless you have a very small number of logs).
This appender doesn't use batch inserts supported by probably all modern RDBMSs.
This appender doesn't user prepare statements.
All-in-all storing logs in RDBMS doesn't really make sense nowadays, logs are meant to be read and analyzed, and RDBMS doesn't offer really handy tools for this (both visual and from the maintenance standpoint: how do delete obsolete messages? Bulk DELETE is very expensive, partitioning? Retention Policies for records are not really supported in many RDBMSs...
So, a much more modern approach is using tools like ElasticSearch + Kibana (+ some log shipper) or even streaming logs to the cloud (like Logz.io)
To Directly address your question:
you should debug this appender to see what happens.
Make sure that DB driver (mysql in this case) appears in the classpath of the application.
Make sure that the table / schema exist, because this appender by its own does not create a schema for you
Note that it has a "bufferSize" parameter, so only if the non-stored message count exceeds the buffer, the actual DB request gets performed.
Place a breakpoint on
org.apache.log4j.jdbc.JDBCAppender#execute
and see how it really executes
Overall observation/side notes, not directly related to your answer but still can be valuable.
This appender is really outdated and is not a really good solution for modern production applications (unless you have a very small number of logs).
This appender doesn't use batch inserts supported by probably all modern RDBMSs.
This appender doesn't user prepare statements.
All-in-all storing logs in RDBMS doesn't really make sense nowadays, logs are meant to be read and analyzed, and RDBMS doesn't offer really handy tools for this (both visual and from the maintenance standpoint: how do delete obsolete messages? Bulk DELETE is very expensive, partitioning? Retention Policies for records are not really supported in many RDBMSs...
So, a much more modern approach is using tools like ElasticSearch + Kibana (+ some log shipper) or even streaming logs to the cloud (like Logz.io)
answered Nov 8 at 5:09
Mark Bramnik
11.2k32445
11.2k32445
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53201735%2flog4j-databse-apender-does-not-work-properly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown