log4j JDBC logging

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg Scharlemann

    log4j JDBC logging

    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.getLogge r("generic");

    and I have the PropertyConfigu rator 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 comes across. I have defined numerous logger.debug() statements
    throughout the code and the first 6 statements throughout various
    classes will be logged, but other logging statements will not.

    So I set up just a stupid Logger that logs to a file on the system and
    placed log statements after each log4j statement that I have in each
    class. The stupid logger will successfully log all of the statements,
    but the log4j statements stop logging after a bit.

    Why would this be? Are statements getting lost because I am
    connecting to the database? The database is on the local machine so I
    couldn't imagine that being the case...does anyone have any ideas?
    Thanks for your thoughts...
  • Petarian

    #2
    Re: log4j JDBC logging

    Are you using JDBCAppender that comes with Log4J? If yes, try calling
    the flushBuffer() method on the appender to flush the cached events.
    Beside, before your program exits call the LogManager.shut down() method.

    Pete.

    Greg Scharlemann wrote:
    [color=blue]
    >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.getLogg er("generic");
    >
    >and I have the PropertyConfigu rator 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 comes across. I have defined numerous logger.debug() statements
    >throughout the code and the first 6 statements throughout various
    >classes will be logged, but other logging statements will not.
    >
    >So I set up just a stupid Logger that logs to a file on the system and
    >placed log statements after each log4j statement that I have in each
    >class. The stupid logger will successfully log all of the statements,
    >but the log4j statements stop logging after a bit.
    >
    >Why would this be? Are statements getting lost because I am
    >connecting to the database? The database is on the local machine so I
    >couldn't imagine that being the case...does anyone have any ideas?
    >Thanks for your thoughts...
    >
    >[/color]

    --

    You don't pay to get spam, why pay to clean it?
    Visit http://www.spammarshall.com to create an account for free
    <http://www.spammarshal l.com>



    Comment

    • Raymond DeCampo

      #3
      Re: log4j JDBC logging

      Greg Scharlemann wrote:[color=blue]
      > 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.getLogge r("generic");
      >
      > and I have the PropertyConfigu rator 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 comes across. I have defined numerous logger.debug() statements
      > throughout the code and the first 6 statements throughout various
      > classes will be logged, but other logging statements will not.
      >
      > So I set up just a stupid Logger that logs to a file on the system and
      > placed log statements after each log4j statement that I have in each
      > class. The stupid logger will successfully log all of the statements,
      > but the log4j statements stop logging after a bit.
      >
      > Why would this be? Are statements getting lost because I am
      > connecting to the database? The database is on the local machine so I
      > couldn't imagine that being the case...does anyone have any ideas?
      > Thanks for your thoughts...[/color]

      Greg,

      I would start by changing the log4j configuration to log to a file
      instead of the database. Then you will know if the problem is specific
      to the database or not.

      Ray

      Comment

      Working...