Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default Log4J JDBCAppender

    I have a log4j.properties where i am using JDBCAppender to log to the database:

    log4j.appender.jdbc.sql=insert into invocation_count (invocation_time, facade_id) values ('%d{yyyy-MM-dd HH:mm:ss}','%m')

    when i do log.debug("msg");

    the datetime and message value are inserted to the database table.

    is there any way to to have the sql as :

    insert into cpm_invocation_count (invocation_time, facade_id, first_name, last_name) values ('%d{yyyy-MM-dd HH:mm:ss}','%m', '%m', '%m')

    so that i can log multiple messages into database multiple columns.

    Thanks & Regards,
    Subhasish Mohanty
    Last edited by Subhasish Mohanty; 02-24-2011 at 07:56 AM. Reason: missed

  2. #2
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Default

    Quote Originally Posted by Subhasish Mohanty View Post
    insert into cpm_invocation_count (invocation_time, facade_id, first_name, last_name) values ('%d{yyyy-MM-dd HH:mm:ss}','%m', '%m', '%m')

    so that i can log multiple messages into database multiple columns.
    You can log the same message (i.e the single message which we usually pass to logger) any number of times in many columns. But, if you want multiple different messages in same row (in different columns), then log4j is not the solution.:(

    You can gather more info on this by looking at the source of log4j's Logger class.

  3. #3
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default Log4J JDBCAppender

    Thanks a lot

  4. #4
    kemot is offline Member
    Join Date
    Sep 2011
    Posts
    1
    Rep Power
    0

    Default Re: Log4J JDBCAppender

    you can execute procedure "call my_procedure('%m')" instead of "insert" then you can extract inside my_procedure from message data and insert them to many columns. But you need pay attention about performance.

Similar Threads

  1. log4j
    By haj1st in forum Eclipse
    Replies: 5
    Last Post: 01-23-2011, 03:17 PM
  2. Replies: 1
    Last Post: 09-20-2010, 09:32 AM
  3. log4j
    By swapna_d in forum New To Java
    Replies: 7
    Last Post: 08-04-2010, 01:23 AM
  4. Regarding Log4j
    By sidiq in forum New To Java
    Replies: 0
    Last Post: 04-07-2008, 08:35 PM
  5. Log4j
    By chakri in forum New To Java
    Replies: 1
    Last Post: 02-08-2008, 11:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •