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 6873139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:01:17+00:00 2026-05-27T04:01:17+00:00

I finally got log4j setup with spring mvc, my log4j properties looks like: #

  • 0

I finally got log4j setup with spring mvc, my log4j properties looks like:

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

# Root logger option
log4j.rootLogger=trace, stdout

Now I don’t want to see any output except from my own code, is there a way to restrict all log messages to a specific namespace?

When I go into production, I don’t want any trace/debug information logged, I guess I have to create a file appender but how would I go about restricting the log messages to only severe type log messages like in a try/catch or something unexpected?

  • 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-27T04:01:17+00:00Added an answer on May 27, 2026 at 4:01 am

    For example (using a ConsoleAppeneder, but same difference):

    log4j.rootLogger=INFO, A1
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
    
    log4j.logger.your.package.to.debug=DEBUG
    log4j.logger.org.springframework.aop=DEBUG
    

    This logs at the INFO level by default, except for the your.package.to.debug and spring-aop packages, logged at the DEBUG level. Mix and match levels and packages however required.

    I’d be wary of not putting INFO into production unless you never need to debug anything, though–particularly during startup, INFO is really important. It can also be used to provide general system information.

    Also, the %L pattern is pretty slow. Fine for rare WARNING/etc. logs, not so much for normal operational logging.

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

Sidebar

Related Questions

I've finally got the datepicker to work on my MVC demo site and also
I've have finally got the datepicker to work on my MVC demo site. One
So I've finally got my WCF service setup and talking to browser via ASP.NET
I finally got to try .NET MVC this weekend and, as was expected, ran
I didn't find any question like this here. Yesterday I finally got Gingerbread 2.3.4
I have finally got my Delphi application to send data using direct sockets with
Yesterday I finally got everything set up for sending to testflightapp.com and also setup
I finally got my group to switch from SourceSafe to Subversion. Unfortunately, my manager
I have finally got the green light to use Memcached in our project (after
I have finally got in my mind what worried me about Dependency Injection and

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.