简体   繁体   中英

Logger is not working in SpringMVC

I have declared Logger in my class, but I cann't see its output when I run my code on Tomcat - Eclipse.

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class TestClassDao implements TestDao{
    protected final Log logger = LogFactory.getLog(getClass());

    public void deleteData(){
        //Do Operation
        logger.info("Deleted rows affected: " + result);
    }

Maven:

<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
</dependency>

When I run the code on Eclipse Kelper using Tomcat Server 7, I am not able to see any output of the logger function.

Can you please suggest what I am missing here?

  1. verify you have log4j configuration file (log4j.properties/log4j.xml) in classpath
  2. In eclipse, double click your server to open configuration tab
  3. Click 'Open launch Configuration'
  4. In 'Arguments' tab, add log4j.debug=true to VM arguments

On starting tomcat check the console messages logged by log4j

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM