H
H
hudrogen2017-05-04 12:34:02
Java
hudrogen, 2017-05-04 12:34:02

How to prevent Spring MVC from writing logs to my log file?

I am learning Spring MVC. To write logs I use

log4j In AppStartListener I initialize the logger. log4j.xml is located in the resources folder The logger is configured to output to a file. Next, I use the standard logger
DOMConfigurator.configure("loj4j.xml");

private static final Logger log = Logger.getLogger(LoginServlet.class);
...
log.trace("trace message");


So Spring writes its logs to the log file too. How can I prevent him from using my logger?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hudrogen, 2017-05-08
@hudrogen

For XML you need to add

<logger name="org.springframework">
        <level value="Warn" />
        <appender-ref ref="consoleAppender"/>
    </logger>

If the logger setting is specified by a property file, you need to add
log4j.logger.org.springframework=INFO

A
aol-nnov, 2017-05-04
@aol-nnov

pick your own "loj4j.xml" if you don't show it here. the solution is there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question