• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

LOG4J Help URGENT!!!!!!!

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if my understanding is not wrong while using LOG4J JDBCappender to write to a DataBase using configurator file(Property file), the SQL will be written in the property file and the message to be logged into the DB will be passed from the program(java file ) to the log4J system using the log.debug or any other way.
for eg: INSERT INTO JDBCTEST (Date, Logger, Priority, Message) VALUES ('%d', '%c', '%p', '%m')
here the only message passed t th eLOG4J system is the Message field value which is

represnted by the %m field(inside the value block) and rest are kind of constants , like for date (where we can use sysdate) and the logger and priority level which all are constants and not part of the message passed to the system(LOG4J system).
the trouble we found was in separating the single message we send to the LOG4J system

for eg: suppose if the message we send to the LOG4J system is
" methodname=ABC() timetaken=1.5secs date=28/7/2006 "
i am confused about the way to split the message into say 3 parts
like

methodname=ABC()
methodname=ABC()
date=28/7/2006

and insert into different columns of the table

Hope you got a good broader view of the problem i am facing.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ashok George,
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular, please see EaseUp to find out how adding "URGENT" to your post or subject line will keep you from getting good answers in a timely manner.



Again, welcome to JavaRanch and good luck with your question.
-Ben
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out (I believe it is either) NDC or MDC. You can define your own LOog4J values and then pick em back out using %U{myval1}

Or something like that. I'd go look for full details but I opted for a faster rather than more concide post
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As David mentioned, you can achieve this through MDC. Have a look at the NDC/MDC section at:

Log4j article

Log4j MDC article

You will find a code sample(MDCUserServletFilter.java) at:
Code sample - this is just a sample, you need not use a servlet.

Then use the [%X{yourVal}] as part of the ConversionPattern of the appender in the log4j.xml
[ July 31, 2006: Message edited by: jaikiran pai ]
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic