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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:18:17+00:00 2026-05-17T17:18:17+00:00

Logger Hi, I have a Spring MVC webapps that needs some server side logging

  • 0

Logger

Hi,

I have a Spring MVC webapps that needs some server side logging so I configured Log4J in my Spring MVC

<listener>
 <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

In my controller, I logged all user transaction.

@Controller
public class MyController {
 protected final Log logger = LogFactory.getLog(getClass());

 public String setup(){
  MyObject object = new MyObject();

  logger.info("User check in data...." + object.data);
 }
}

I have some questions though:

  1. Are Logging in a Spring MVC Webapps considered a costly transaction? I mean will this slowdown my app?
  2. In a production enviroment, will it be OK if I leave out this logger.info? I need to add this for traceability of each transaction and is a requirement
    but I am worried about the impact of these.

Thanks

  • 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-17T17:18:17+00:00Added an answer on May 17, 2026 at 5:18 pm

    Log4j has almost no overhead itself. It is designed to be compiled into your code and enabled or disabled by configuration.

    When it is disabled, it is very fast. The only problem you may have is in preparing the log message, which will then not be used. You can avoid this with a guard:

     if (logger.isInfoEnabled()){  // in case object.data.toString() is costly
        logger.info("User check in data...." + object.data);
     }
    

    When it is enabled, it obviously takes some time to write the message to the log file/daemon/database. However, since you have enabled it, you need that log message (you say you have a traceability requirement), so the fair comparison would be to creating the log message in another way. And here, the log4j overhead (versus calling the logging backend directly) is minimal.

    The full cost of logging the message will thus be determined by what kind of backend you are using (and not by log4j itself).

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

Sidebar

Related Questions

I have Spring MVC setup to log exceptions using commons logging, but find that
I have a logger class that is used all across my application, both in
I have a Spring MVC and Resteasy based REST service that i need to
I have a Spring MVC web app running on my server. Recently I wanted
I have an application built on Spring MVC that uses Hibernate for all of
I have a Spring MVC REST service that uses XStream to convert the messages
I have written some dirty code that retrieves user email in MVC. As you
I have a logger in a c++ application that uses defines as follows: #define
I have a python logger set up, using python's logging module. I want to
I have some files: core.php : require_once 'logger.php'; require_once 'smth_else.php'; $Logger = new Logger();

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.