Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7751799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:38:23+00:00 2026-06-01T11:38:23+00:00

Using log4j, I used to have an appender that logs directly to one of

  • 0

Using log4j, I used to have an appender that logs directly to one of the tables in my database. The appender was as follows:

 <appender name="DATABASE_LOG" class="org.apache.log4j.jdbc.JDBCAppender">
        <param name="URL" value="jdbc:postgresql://localhost/registrationdb" />
        <param name="Driver" value="org.postgresql.Driver"/>
        <param name="User" value="postgres"/>
        <param name="Password" value="********/>
        <layout class="org.apache.log4j.EnhancedPatternLayout">
            <param name="ConversionPattern" value="INSERT INTO user (user_id,creation_datetime,comment,user_type) VALUES ('%X{userId}','%d{yyyy-MM-dd HH:mm:ss}','%X{comment}','%X{userType}')"/>
        </layout>
        <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMin" value="DEBUG" />
            <param name="LevelMax" value="INFO" />
        </filter>
  </appender>

The log4j was part of a web application that’s deployed on JBoss 4.2. The problem with log4j was that it wasn’t closing the database connection it’s opening, and even when we tried a Postgres data source on the web server, it was depleting all the connections in the pool(This is a whole different issue). This is why we decided to try LogBack, to see if it’s any better. Interestingly, when I read the LogBack documentation, it clearly mentioned the following:

The DBAppender inserts logging events into three database tables in a
format independent of the Java programming language.

These three tables are logging_event, logging_event_property and
logging_event_exception. They must exist before DBAppender can be
used.

To my understanding, this means that I’m bound to those 3 tables to log to the database.

Searching for solutions on the internet has yielded very few results that involved extending the AppenderBase class which is not convenient for me at this stage, since this means that more testing will have to be done, knowing that we have plenty of other requirements to test. The question is: Can I define an appender for LogBack that’s similar in functionality to my log4j appender above?

Your help is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:38:24+00:00Added an answer on June 1, 2026 at 11:38 am

    Yes, Logback requires 3 database tables, you cannot skip any of them, you can only customize their names. This is actually an advantage, Log4J didn’t log exceptions at all, while Logback uses a separate table for stack trace lines. It also logs mdc properties (third table).

    If you wish to customize table and/or column names, you can implement DBNameResolver.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have sixteen servers using Log4J logs, accessible by ssh. I want to see
So we have our J2EE application using Log4j like this public class CustomerController {
This is my Student class that used to test log4j. public class Student{ private
i am using log4j and my configuration is as follows: log4j.rootLogger=OFF, stdout, rootLog log4j.appender.stdout=org.apache.log4j.ConsoleAppender
I have developed a web project. Which is generating log file using log4j. But
I have discovered some issues in my program. I was using log4j for logging,
I am used to using Tomcat/Log4J for my logging. My current project is deployed
I'm using the org.jboss.logging.Logger class, and seem to have come across an incongruity. When
I can't configure org.hibernate.type (logging bind variables used in hibernate prepared statements) using log4j.xml,
I have created a Java application that has 2 Jar files. Jar1 is used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.