473,811 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

log4j problem in database.

rsrinivasan
221 New Member
Hi,
I am using log4j to create log message. I want to write the log message to database. So i configured the log4j.propertie s files like this...


Expand|Select|Wrap|Line Numbers
  1. # Database Configuration
  2. log4j.appender.dbase          =org.apache.log4j.jdbc.JDBCAppender
  3. log4j.appender.dbase.layout   =org.apache.log4j.PatternLayout
  4. log4j.appender.dbase.driver   =com.microsoft.sqlserver.jdbc.SQLServerDriver
  5. log4j.appender.dbase.URL      =jdbc:sqlserver://win2003:1433/MyApp
  6. log4j.appender.dbase.user     =user
  7. log4j.appender.dbase.password =password
  8. #log4j.appender.dbase.sql     =INSERT INTO JDBCTEST VALUES ('%d - %c - %p - %m')
But i have the following errors. Where im going to wrong...

Expand|Select|Wrap|Line Numbers
  1. log4j:ERROR Failed to excute sql
  2. com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433/Pricing is not valid.
  3.     at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
  4.     at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
  5.     at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
  6.     at java.sql.DriverManager.getConnection(DriverManager.java:512)
  7.     at java.sql.DriverManager.getConnection(DriverManager.java:171)
  8.     at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:212)
  9.     at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:175)
  10.     at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
  11.     at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
  12.     at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
  13.     at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
  14.     at org.apache.log4j.Category.callAppenders(Category.java:206)
  15.     at org.apache.log4j.Category.forcedLog(Category.java:391)
  16.     at org.apache.log4j.Category.log(Category.java:856)
Dec 20 '07 #1
4 7426
r035198x
13,262 MVP
Hi,
I am using log4j to create log message. I want to write the log message to database. So i configured the log4j.propertie s files like this...


Expand|Select|Wrap|Line Numbers
  1. # Database Configuration
  2. log4j.appender.dbase          =org.apache.log4j.jdbc.JDBCAppender
  3. log4j.appender.dbase.layout   =org.apache.log4j.PatternLayout
  4. log4j.appender.dbase.driver   =com.microsoft.sqlserver.jdbc.SQLServerDriver
  5. log4j.appender.dbase.URL      =jdbc:sqlserver://win2003:1433/MyApp
  6. log4j.appender.dbase.user     =user
  7. log4j.appender.dbase.password =password
  8. #log4j.appender.dbase.sql     =INSERT INTO JDBCTEST VALUES ('%d - %c - %p - %m')
But i have the following errors. Where im going to wrong...

Expand|Select|Wrap|Line Numbers
  1. log4j:ERROR Failed to excute sql
  2. com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433/Pricing is not valid.
  3.     at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
  4.     at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
  5.     at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
  6.     at java.sql.DriverManager.getConnection(DriverManager.java:512)
  7.     at java.sql.DriverManager.getConnection(DriverManager.java:171)
  8.     at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:212)
  9.     at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:175)
  10.     at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
  11.     at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
  12.     at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
  13.     at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
  14.     at org.apache.log4j.Category.callAppenders(Category.java:206)
  15.     at org.apache.log4j.Category.forcedLog(Category.java:391)
  16.     at org.apache.log4j.Category.log(Category.java:856)
I'm not sure what your URL format should be but as you can see from the exception it's trying to use 1433/Pricing as the port. Perhaps you should have separated the 1433 and the Procing with a colon(:)?
Dec 20 '07 #2
rsrinivasan
221 New Member
I'm not sure what your URL format should be but as you can see from the exception it's trying to use 1433/Pricing as the port. Perhaps you should have separated the 1433 and the Procing with a colon(:)?
I separated my port number and and MyApp(Pricing) by colon(:). Still i have the same error like this..

Expand|Select|Wrap|Line Numbers
  1. com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433:Pricing is not valid.
  2.     at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
  3.     at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
  4.     at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
  5.     at java.sql.DriverManager.getConnection(DriverManager.java:512)
  6.     at java.sql.DriverManager.getConnection(DriverManager.java:171)
  7.     at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:212)
  8.     at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:175)
  9.     at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
  10.     at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
  11.     at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
  12.  
In this,

Expand|Select|Wrap|Line Numbers
  1.  win2001 --> is my database server name
  2.     1433      --> is the my database access port number
  3.     Pricing   --> is my Web application
What to do?

Thanks,
Dec 20 '07 #3
r035198x
13,262 MVP
I separated my port number and and MyApp(Pricing) by colon(:). Still i have the same error like this..

Expand|Select|Wrap|Line Numbers
  1. com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433:Pricing is not valid.
  2.     at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
  3.     at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
  4.     at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
  5.     at java.sql.DriverManager.getConnection(DriverManager.java:512)
  6.     at java.sql.DriverManager.getConnection(DriverManager.java:171)
  7.     at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:212)
  8.     at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:175)
  9.     at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
  10.     at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
  11.     at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
  12.  
In this,

Expand|Select|Wrap|Line Numbers
  1.  win2001 --> is my database server name
  2.     1433      --> is the my database access port number
  3.     Pricing   --> is my Web application
What to do?

Thanks,
What if you don't put the application name at the end of the port?

P.S I'm clutching at straws here. The correct thing would be to read about what the URL format should be like.
Dec 20 '07 #4
rsrinivasan
221 New Member
What if you don't put the application name at the end of the port?

P.S I'm clutching at straws here. The correct thing would be to read about what the URL format should be like.
URL is ==> http://localhost:8201/Pricing

I have the Error(Exception ), when i deploy my application.

Thanks,
Dec 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
180329
by: Aaron Boxer | last post by:
Hello, My application is using a jar file MyJar.jar that uses log4j (I have the latest release of log4j). I have put both MyJar.jar and log4j.jar in a directory in my classpath. I have also put the file "log4j.properties" into this same directory. My log4j.properties file reads:
2
7919
by: Greg Scharlemann | last post by:
I have a various different packages within this web application that I am writing and I am attempting to set up log4j to log directly to a database. So each class is calling just a generic logger: Logger.getLogger("generic"); and I have the PropertyConfigurator read in some properties from a log file that define the database connection, the user, pass, ... The logging to the database works, but it does not log every statement it...
1
5989
by: Adi | last post by:
Hi, I have a web application (using J2EE) which runs on 3 tomcats (4.0) for Load Balancing. I have recently started to use the Log4j in this application. Currently the logs for this application is of the tomcat's(System.out.println...) - and because there are 3 tomcats there are 3 logs. The log4j writes to one file only. My question is: How can I tell in the log4j log from which server the request came
1
5607
by: Ragavendra BC | last post by:
Log4j Issue ----------- Hi, I am facing a problem related to Log4j... The problem is such that I have two different Log4j files one in ..properties format and the other in the .xml format.. and their source code is like this
2
2008
by: Hari2349 | last post by:
Regarding to log4j in java program..Plz help me... -------------------------------------------------------------------------------- Hai, friends i used the log4j.properties file like as below...... log4j.rootLogger=VERBOSE, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppe nder
1
5524
by: Kedar Kachare | last post by:
How to use Log4j to create log files using file appender in a Servlet? Also, how to make that Servlet read the log4j.properties file? I have tried following: My web.xml( I use Eclipse europa) <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"...
0
5724
by: Mikhail Teterin | last post by:
Hello! I'm trying to use log4j's SMTPAppender to get warnings and errors reported by our application via e-mail (in addition to having ALL messages saved into a file via RollingFileAppender). It all works, except for one thing -- every warning/error arrives in its own e-mail message... The BufferSize parameters appears intended to regulate this, but no matter
0
1403
by: msg2ajay | last post by:
hello, I have configured %CATALINA_HOME% in Win Environ.But as I configured to "${catalina.home}/MQLog/info/info.log" for "file" in log4j.xml I can't see the log file after running my application. i have place INFO in my code, I can see INFO log in Tomcat console, my log4j.xml file is as below. --------------------------- <?xml version="1.0" encoding="UTF-8"?>
5
4116
by: Abhinay | last post by:
Hi there, I am working on server which used thread pool to process each client request by separate dedicated thread. My intention was each thread ( of thread pool ) have its own logger and hence all client processed by that thread must be logged in corresponding thread specific logger. My problem is that logger merging log content with other logger content, my doubt is Logger.getLogger(...) function return wrong logger object. I am...
0
9726
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10384
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10395
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10130
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6887
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5553
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.