• Post Reply Bookmark Topic Watch Topic
  • New Topic

ms sql with log4j  RSS feed

cc sekhar
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#this is my kk.xml file

# This defines the logging level for the rootLogger. It is not required
# if you are going to keep the level at debug as the rootLogger by default
# is at the debug level. The value after the comma is the appender for the
# root and we have given it the name R
log4j.rootLogger=debug, R
# Since we plan to log to a database, we tell log4j that we will use the
# JDBCAppender. To complete the configuration for this, we need to tell
# some basic things to this appender. Database, Username, password and the
# actual values to log. %m represents the message that will be generated by
# our log statements.
log4j.appender.R.URL=jdbc dbc:emp
log4j.appender.R.sql=INSERT INTO testme VALUES (10,'madu')
# These definea the layout to be used.
#this is my log4j java file

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
public class externalplaintest {
static Logger logger = Logger.getLogger(externalplaintest.class);
public static void main(String args[]) {
logger.debug("Here is some DEBUG");
logger.info("Here is some INFO");
logger.warn("Here is some WARN");
logger.error("Here is some ERROR");
logger.fatal("Here is some FATAL");

while i am running the above code i am getting the problem
log4j:error could not instantiate the appender named jdbc2.
if i use jdbc2 instead of R(root).i am getting some other exception.
i am new to log4j.
so any one could help me to solve this problem
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!