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

  • Home
  • SEARCH
  • 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 7590683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:27:58+00:00 2026-05-30T20:27:58+00:00

I have the following in log4j.xml file, when I run my application. Only error

  • 0

I have the following in log4j.xml file, when I run my application. Only error logs are getting printed in console, info logs are not getting printed. But if I comment out jdbcAppender part and only use

I would like to have both error and info to printed and at the same time error logs needs to be inserted into database table errors.

How can I do this?

Regards

<appender name="jdbcAppender" class="bean.CustomJdbcAppender"> 
        <param name = "jndiDataSource" value="myjdbcDS"/>        
        <layout class="org.apache.log4j.PatternLayout"> 
            <param name="ConversionPattern" 
              value="INSERT INTO errors (log_level, location, message) VALUES ( '%p',
              '%C;%L', '%m' )" 
            /> 
        </layout> 
    </appender>
    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"> 
        <layout class="org.apache.log4j.PatternLayout"> 
            <param name="ConversionPattern" 
              value="%d{ISO8601} %p (%C;%L) %m%n" 
            /> 
        </layout> 
    </appender> 
    <category name="bean"><priority value="error"/>
    <appender-ref ref="jdbcAppender"/> 
    </category>
    <root> 
        <priority value="info"/> 
        <appender-ref ref="STDOUT"/> 
    </root> 
  • 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-05-30T20:27:59+00:00Added an answer on May 30, 2026 at 8:27 pm

    Remove ERROR priority from the logger bean such that its logging level is inherited from the root logger , which is set to the INFO level . Then any logging events coming from this logger which level is larger or equal to INFO can be intercepted and forward to the jdbcAppender and STDOUT .

      <category name="bean">
        <appender-ref ref="jdbcAppender"/> 
      </category>
    

    To restrict only the ERROR level events can be actually logged by jdbcAppender , apply and configure the LevelMatchFilter and DenyAllFilter on the jdbcAppender

    <appender name="jdbcAppender" class="bean.CustomJdbcAppender"> 
            <param name = "jndiDataSource" value="myjdbcDS"/>        
            <layout class="org.apache.log4j.PatternLayout"> 
               <param name="ConversionPattern" value="INSERT INTO errors (log_level, location, message) VALUES ( '%p','%C;%L', '%m' )"  /> 
            </layout> 
            <filter class="org.apache.log4j.varia.LevelMatchFilter">
                      <param name="LevelToMatch" value="error" />
                      <param name="AcceptOnMatch" value="true"/>
            </filter>
            <filter class="org.apache.log4j.varia.DenyAllFilter" />
     </appender>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following log4j.xml configuration: <log4j:configuration> <appender name = CONSOLE class = org.apache.log4j.ConsoleAppender>
I have the following in my log4j file #set httpclient debug levels log4j.logger.org.apache.component=ERROR,stdout log4j.logger.httpclient.wire=ERROR,stdout
The log4j logs I have contain timestamps in the following format: 2009-05-10 00:48:41,905 I
I have implement a log4j.xml file having two loggers. Both EventLogger and ErrorLogger logged
I have following information in log4j.properties file.. log4j.appender.file = org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File = C:\\app\\file.log log4j.appender.file.Threshold
Suppose i have a configuration file like the following to start my application. How
I have following XML configration i would like to convert to java property file.
I have the following for my log4j DSL configuration in Grails 1.2: log4j =
I have following text in a file 23456789 When I tried to replace the
I have the following syntax problem. I have a jar file that is created

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.