Announcement Announcement Module
Collapse
No announcement yet.
Regarding generation of logs for spring MVC Application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Regarding generation of logs for spring MVC Application

    Hi Folks,
    I have developed an spring mvc application which is executing perfectly on tomcat , but the logs I am getting of the server tomcat is on console , I want that logs to be stored in a file ,in other words I want tomcat logs and events that are shown on console to be get stored on a file , I have tried log 4j of apache and below is the properties file I am using..

    Code:
      ### direct messages to file or.log ###
    log4j.appender.file=org.apache.log4j.FileAppender
    log4j.appender.file.File=C:/logs/springmvc.log
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1} - %m%n
    log4j.appender.file.append=true
    
    ### set log levels - for more verbose logging change 'info' to 'debug' ##
    log4j.rootCategory=ALL, file
    log4j.logger.Demo=\=debug
    log4j.logger.org.eclipse=debug
    and the main class.. on which I want log.info statements to be get recorded..

    Code:
    public class HelloWorldController extends AbstractController{
        protected final Log logger = LogFactory.getLog(getClass());
        @Override
        protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
            logger.info("Returning hello view");
            ModelAndView model = new ModelAndView("HelloWorldPage");
            model.addObject("msg", "saral saxreva");
    
            return model;
        }
    }
    but still the logs are not generated in seprate file , please advise what modifications need to be done in my code for seprate log file generation, I am even attaching my application , Please advise

  • #2
    Hello

    With the best intentions, check some Log4j/slf4j tutorial.
    It is not related with Spring, about the .properpies file, in none place you are indicating to log your own controller classes

    Comment


    • #3
      Previous poster is right, this isn't a Spring question. Your log4j properties file looks wrong though:
      log4j.logger.Demo=\=debug

      I don't know what the \= is in there for, perhaps a cut n' paste error? Should just be:
      log4j.logger.Demo=debug

      Comment

      Working...
      X